diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-01 17:47:08 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-01 17:47:44 -0800 |
commit | 6074133396839db40e37aa3c0935edf875d4beba (patch) | |
tree | d9bfb61e7201c3d77a1f1bbad21f29f7a021e31c /core/src/main/scala | |
parent | e1241f1da8e55cfba3286c438ac26e4d09df63ff (diff) | |
download | mill-6074133396839db40e37aa3c0935edf875d4beba.tar.gz mill-6074133396839db40e37aa3c0935edf875d4beba.tar.bz2 mill-6074133396839db40e37aa3c0935edf875d4beba.zip |
Fix `idea` project generation, and make `Result.Exception` display the offending stack trace so they're easier to debug
Diffstat (limited to 'core/src/main/scala')
-rw-r--r-- | core/src/main/scala/mill/eval/Evaluator.scala | 6 | ||||
-rw-r--r-- | core/src/main/scala/mill/eval/Result.scala | 4 | ||||
-rw-r--r-- | core/src/main/scala/mill/main/RunScript.scala | 5 |
3 files changed, 8 insertions, 7 deletions
diff --git a/core/src/main/scala/mill/eval/Evaluator.scala b/core/src/main/scala/mill/eval/Evaluator.scala index e9b34204..5aa3439c 100644 --- a/core/src/main/scala/mill/eval/Evaluator.scala +++ b/core/src/main/scala/mill/eval/Evaluator.scala @@ -214,9 +214,9 @@ class Evaluator[T](val workspacePath: Path, target.evaluate(args) } } - }catch{ - case NonFatal(e) => - Result.Exception(e) + }catch{ case NonFatal(e) => + val currentStack = new Exception().getStackTrace + Result.Exception(e, currentStack) }finally{ System.setErr(err) System.setOut(out) diff --git a/core/src/main/scala/mill/eval/Result.scala b/core/src/main/scala/mill/eval/Result.scala index e0cc18bb..a9b2c70b 100644 --- a/core/src/main/scala/mill/eval/Result.scala +++ b/core/src/main/scala/mill/eval/Result.scala @@ -4,11 +4,11 @@ sealed trait Result[+T] object Result{ implicit def create[T](t: => T): Result[T] = { try Success(t) - catch { case e: Throwable => Exception(e) } + catch { case e: Throwable => Exception(e, new java.lang.Exception().getStackTrace) } } case class Success[T](value: T) extends Result[T] case object Skipped extends Result[Nothing] sealed trait Failing extends Result[Nothing] case class Failure(msg: String) extends Failing - case class Exception(throwable: Throwable) extends Failing + case class Exception(throwable: Throwable, outerStack: Seq[StackTraceElement]) extends Failing }
\ No newline at end of file diff --git a/core/src/main/scala/mill/main/RunScript.scala b/core/src/main/scala/mill/main/RunScript.scala index 53347fd6..34a569fb 100644 --- a/core/src/main/scala/mill/main/RunScript.scala +++ b/core/src/main/scala/mill/main/RunScript.scala @@ -1,6 +1,6 @@ package mill.main -import java.io.PrintStream +import java.io.{ByteArrayOutputStream, PrintStream} import java.nio.file.NoSuchFileException import ammonite.interp.Interpreter @@ -127,7 +127,8 @@ object RunScript{ case Right(t) => Mirror.renderSelector(t.segments.toList) } val fss = fs.map{ - case Result.Exception(t) => t.toString + case Result.Exception(t, outerStack) => + t.toString + t.getStackTrace.dropRight(outerStack.length).map("\n " + _).mkString case Result.Failure(t) => t } s"$ks ${fss.mkString(", ")}" |