diff options
author | Matt Farmer <matt@frmr.me> | 2016-03-12 11:45:43 -0500 |
---|---|---|
committer | Matt Farmer <matt@frmr.me> | 2016-03-12 11:45:43 -0500 |
commit | d21fa548ff16537e98f90b4cd4adadd942dd1f05 (patch) | |
tree | 16986e37eba0653a9b14a562c5c9033d020de47d /stage2 | |
parent | 0f8173956453525cd69861b5e12149ae8d1084c3 (diff) | |
download | cbt-d21fa548ff16537e98f90b4cd4adadd942dd1f05.tar.gz cbt-d21fa548ff16537e98f90b4cd4adadd942dd1f05.tar.bz2 cbt-d21fa548ff16537e98f90b4cd4adadd942dd1f05.zip |
Properly bubble error codes from tasks.
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/Lib.scala | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala index edbb80d..60e7dd4 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -173,17 +173,21 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ .flatMap(toTask _) .map{ methodSymbol => val result = mirror.reflect(obj).reflectMethod(methodSymbol)() + // Try to render console representation. Probably not the best way to do this. - val method = scala.util.Try( result.getClass.getDeclaredMethod("toConsole") ) - - method.foreach(m => println(m.invoke(result))) - method.recover{ - case e:NoSuchMethodException if e.getMessage contains "toConsole" => + scala.util.Try( result.getClass.getDeclaredMethod("toConsole") ) match { + case scala.util.Success(m) => + println(m.invoke(result)) + + case scala.util.Failure(e) if e.getMessage contains "toConsole" => result match { case () => "" case ExitCode(code) => System.exit(code) case other => println( other.toString ) // no method .toConsole, using to String } + + case scala.util.Failure(e) => + throw e } }.getOrElse{ taskName.foreach{ n => |