2011-06-26 101 views
18

我使用SBT 0.10.0來編譯Java和Scala文件的組合。如何在SBT 0.10.0中獲得完整的堆棧跟蹤?

Nonzero exit code: 1 

如果我通過scala命令行運行程序,它的作用: - 當我運行通過sbt run它返回一個非零錯誤,但沒有告訴我一個堆棧跟蹤程序簡單地用晦澀的消息靜默方式失敗顯示堆棧跟蹤。

有什麼辦法可以讓SBT打印出整個堆棧跟蹤?

+1

我不確定它是否會有所幫助,但是您是否嘗試在build.sbt中添加'logLevel:= Level.Error'。 –

回答

14

執行sbt進入sbt shell,然後嘗試run後跟last run

last <command>輸出命令產生的所有東西(所有日誌級別,包括[debug])和堆棧跟蹤。

5

last run,如圖所示here,是要走的路,但如果你正在做的事情就像在~ run一個循環中運行,只是想看看你的應用程序的異常也可以是惱人。你可以告訴SBT啓用自動打印堆棧跟蹤這樣的任務:

traceLevel in run := 0 

進一步參考here

0

在SBT 0.13.x中,堆棧跟蹤被打印出來,所以現在問題可能已經變得不相關。

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 
相關問題