diff options
author | Lex Spoon <lex@lexspoon.org> | 2006-02-28 17:45:10 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2006-02-28 17:45:10 +0000 |
commit | e8384f4f32b0df48cf231e56f72219edd861f43d (patch) | |
tree | 58ad8e44d22b94f91608e16befb890bc5e3c53e8 | |
parent | bbcf2deba1a69a40f6dfe8b7a79d6b487cf592d1 (diff) | |
download | scala-e8384f4f32b0df48cf231e56f72219edd861f43d.tar.gz scala-e8384f4f32b0df48cf231e56f72219edd861f43d.tar.bz2 scala-e8384f4f32b0df48cf231e56f72219edd861f43d.zip |
catch exceptions when running the resulting cod...
catch exceptions when running the resulting code, and print a nice stack
trace
-rw-r--r-- | src/compiler/scala/tools/nsc/Interpreter.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 217823d2a9..204788e74d 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -402,7 +402,16 @@ class Interpreter(val compiler: Global, output: (String => Unit)) { def loadAndRun: String = { val interpreterResultObject: Class = Class.forName(resultObjectName,true,classLoader) val resultValMethod: java.lang.reflect.Method = interpreterResultObject.getMethod("result",null) - resultValMethod.invoke(interpreterResultObject,null).toString() + try { + resultValMethod.invoke(interpreterResultObject,null).toString() + } catch { + case e => { + def caus(e: Throwable): Throwable = + if(e.getCause == null) e else caus(e.getCause) + val orig = caus(e) + stringFrom(str => orig.printStackTrace(str)) + } + } } /** return a summary of the defined methods */ |