mirror of https://github.com/sbt/sbt.git
log toString of exception in non-main threads to indicate a trace exists. fixes #157
This commit is contained in:
parent
9ebf809259
commit
b40a2f31ea
|
|
@ -38,7 +38,7 @@ object TrapExit
|
||||||
code.set(1) //exceptions in the main thread cause the exit code to be 1
|
code.set(1) //exceptions in the main thread cause the exit code to be 1
|
||||||
throw x
|
throw x
|
||||||
}
|
}
|
||||||
val customThreadGroup = new ExitThreadGroup(new ExitHandler(Thread.getDefaultUncaughtExceptionHandler, originalThreads, code, log))
|
val customThreadGroup = new ExitThreadGroup(new ExitHandler(originalThreads, code, log))
|
||||||
val executionThread = new Thread(customThreadGroup, "run-main") { override def run() { executeMain } }
|
val executionThread = new Thread(customThreadGroup, "run-main") { override def run() { executeMain } }
|
||||||
|
|
||||||
val originalSecurityManager = System.getSecurityManager
|
val originalSecurityManager = System.getSecurityManager
|
||||||
|
|
@ -168,7 +168,7 @@ object TrapExit
|
||||||
}
|
}
|
||||||
/** An uncaught exception handler that delegates to the original uncaught exception handler except when
|
/** An uncaught exception handler that delegates to the original uncaught exception handler except when
|
||||||
* the cause was a call to System.exit (which generated a SecurityException)*/
|
* the cause was a call to System.exit (which generated a SecurityException)*/
|
||||||
private final class ExitHandler(originalHandler: Thread.UncaughtExceptionHandler, originalThreads: Set[Thread], codeHolder: ExitCode, log: Logger) extends Thread.UncaughtExceptionHandler
|
private final class ExitHandler(originalThreads: Set[Thread], codeHolder: ExitCode, log: Logger) extends Thread.UncaughtExceptionHandler
|
||||||
{
|
{
|
||||||
def uncaughtException(t: Thread, e: Throwable)
|
def uncaughtException(t: Thread, e: Throwable)
|
||||||
{
|
{
|
||||||
|
|
@ -180,8 +180,8 @@ object TrapExit
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
case _ =>
|
case _ =>
|
||||||
|
log.error("(" + t.getName + ") " + e.toString)
|
||||||
log.trace(e)
|
log.trace(e)
|
||||||
originalHandler.uncaughtException(t, e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ $ exists flag
|
||||||
$ delete flag
|
$ delete flag
|
||||||
|
|
||||||
$ mkdir "forked"
|
$ mkdir "forked"
|
||||||
> set fork :== true
|
> set fork := true
|
||||||
> 'set baseDirectory in run <<= baseDirectory(_ / "forked")'
|
> 'set baseDirectory in run <<= baseDirectory(_ / "forked")'
|
||||||
|
|
||||||
> run "forked"
|
> run "forked"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue