Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get full stacktrace in SBT 0.10.0?

Tags:

scala

sbt

I'm using SBT 0.10.0 to compile a combination of Java and Scala files. When I run the program through sbt run it returns a nonzero error but doesn't show me a stacktrace -- it simply fails silently with the cryptic message:

Nonzero exit code: 1

If I run the program through scala command line, it does show the stacktrace.

Is there any way I can get SBT to print out the entire stacktrace?

like image 614
user747980 Avatar asked Jun 26 '11 01:06

user747980


People also ask

How do you print a full Stacktrace?

Using printStackTrace() method − It print the name of the exception, description and complete stack trace including the line where exception occurred. Using toString() method − It prints the name and description of the exception. Using getMessage() method − Mostly used. It prints the description of the exception.


2 Answers

Execute sbt to get into the sbt shell, then try run followed by last run.

last <command> outputs everything that the command produced (all log levels, including [debug]) and stacktraces.

like image 138
Fred Dubois Avatar answered Sep 27 '22 21:09

Fred Dubois


last run, as shown here, is the way to go, but it can be annoying if you are doing something like running in a loop with ~ run and just want to see your app's exceptions. You can tell SBT to enable printing the stack traces automatically for a task like this:

traceLevel in run := 0

Further reference here.

like image 24
overthink Avatar answered Sep 27 '22 21:09

overthink