package group.matsen.phylohmc

import java.io.File

import ammonite.ops.Path
import ammonite.util.Res.{Exception, Failure}

object Main extends App {

  ammonite.Main(predef = "import " + getClass.getPackage.getName + "._", verboseOutput = false).runScript(Path(new File(args(0)).getAbsolutePath), Seq.empty, Seq.empty) match {
    case Failure(ex, msg) =>
      ex match {
        case Some(t) => throw t
        case None => System.err.println(msg)
      }
    case Exception(t, msg) => throw t
    case _ =>
  }

}

package group.matsen.phylohmc

import java.io.File

import ammonite.ops.Path

object Main extends App {

  ammonite.Main(predef = "import " + getClass.getPackage.getName + "._", verboseOutput = false).runScript(Path(new File(args(0)).getAbsolutePath), Seq.empty, Seq.empty)

}

--- 
+++ 
@@ -3,9 +3,18 @@
 import java.io.File
 
 import ammonite.ops.Path
+import ammonite.util.Res.{Exception, Failure}
 
 object Main extends App {
 
-  ammonite.Main(predef = "import " + getClass.getPackage.getName + "._", verboseOutput = false).runScript(Path(new File(args(0)).getAbsolutePath), Seq.empty, Seq.empty)
+  ammonite.Main(predef = "import " + getClass.getPackage.getName + "._", verboseOutput = false).runScript(Path(new File(args(0)).getAbsolutePath), Seq.empty, Seq.empty) match {
+    case Failure(ex, msg) =>
+      ex match {
+        case Some(t) => throw t
+        case None => System.err.println(msg)
+      }
+    case Exception(t, msg) => throw t
+    case _ =>
+  }
 
 }
Throw exceptions encountered while running script
