开发者

How to get full stacktrace in SBT 0.10.0?

开发者 https://www.devze.com 2023-03-15 16:08 出处:网络
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

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?


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.


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.


In SBT 0.13.x, the stack trace's printed out so the question might've become irrelevant now.

jacek:~/sandbox/so/sbt-0.13.1
$ sbt run
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/so/sbt-0.13.1/project
[info] Set current project to sbt-0-13-1 (in build file:/Users/jacek/sandbox/so/sbt-0.13.1/)
[info] Compiling 1 Scala source to /Users/jacek/sandbox/so/sbt-0.13.1/target/scala-2.10/classes...
[info] Running MyApp
[error] (run-main-0) java.lang.Exception: exception
java.lang.Exception: exception
    at MyApp$delayedInit$body.apply(Hello.scala:2)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:71)
    at scala.App$$anonfun$main$1.apply(App.scala:71)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
    at scala.App$class.main(App.scala:71)
    at MyApp$.main(Hello.scala:1)
    at MyApp.main(Hello.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
    at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
[error] Total time: 10 s, completed Jan 16, 2014 12:37:25 AM
0

精彩评论

暂无评论...
验证码 换一张
取 消