Scala stack traces are complex, mostly because of the way anonymous functions are translated to bytecode. Here's a example:
java.lang.IllegalStateException
at com.company.IdentityVerifier$$anonfun$go$2$$anonfun$apply$2.apply$mcII$sp(IdentityVerifier.scala:19)
at com.company.IdentityVerifier$$anonfun$go$2$$anonfun$apply$2.apply(IdentityVerifier.scala:17)
at com.company.IdentityVerifier$$anonfun$go$2$$anonfun$apply$2.apply(IdentityVerifier.scala:17)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at com.company.IdentityVerifier$$anonfun$go$2.apply(IdentityVerifier.scala:17)
at com.company.IdentityVerifier$$anonfun$go$2.apply(IdentityVerifier.scala:16)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
at com.company.IdentityVerifier$.go(IdentityVerifier.scala:16)
at com.company.UserMap.setLastUserId(UserMap.scala:12)
at com.company.UserConsumer.setCurrentUser(UserConsumer.java:69)
at com.company.UserConsumer.consume(UserConsumer.java:64)
at com.company.UserProducer.execute(UserProducer.java:19)
at com.company.UserCreator.execute(UserCreator.java:18)
at com.company.UserCreatorMain$1.run(UserCreatorMain.java:37)
at com.company.UserCreatorMain.main(UserCreatorMain.java:51)
I've found stackifier (it's their example), but it's a pain to keep pasting stack traces to a webpage. Is there a way to print "better" stack traces automatically?
Logging the stack traces of runtime exceptions assists developers in diagnosing runtime failures. However, unnecessary logging of exception stack traces can have many negative impacts such as polluting log files.
A call stack is typically "the current stack of operations" - i.e. while it's running. A stack trace is typically a copy of the call stack which is logged at some sort of failure, e.g. an exception.
The first line in the call stack represents the last executed function call, so remember to always read a stack trace top-down.
Intellij IDEA helps, even in the case you are not debugging the code (and the scala plugin should work even with the community version) :
http://www.jetbrains.com/idea/webhelp/analyzing-external-stacktraces.html
You get a clickable stack trace that jumps to the right place.
I asked at ScalaIDE forums whether ScalaIDE does this too. Mirco Dotta ninja-responded:
Yes it does, but it's not the simplest feature to find in Eclipse. You need to open the "Java StackTrace Console"
Haven't asked about emacs, somebody please chip in.
Also, please try to consider that "cryptic" names (go see c++ name mangling) is a price you pay for added flexibility.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With