diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-29 20:11:35 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-29 20:11:35 +0000 |
commit | c36e3cc0a6599092f752ec7304d164cc06b9739c (patch) | |
tree | 3b6b31febeb3a74f8a66e4a4e2fa3ebb4d7d435d /src/compiler | |
parent | fcc62d3da6142acaea96f67fc6ee296085c1971b (diff) | |
download | scala-c36e3cc0a6599092f752ec7304d164cc06b9739c.tar.gz scala-c36e3cc0a6599092f752ec7304d164cc06b9739c.tar.bz2 scala-c36e3cc0a6599092f752ec7304d164cc06b9739c.zip |
Exception handling approaching platonic ideal.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/Interpreter.scala | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index c4f4a38ff8..4869ff04f1 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -763,19 +763,20 @@ class Interpreter(val settings: Settings, out: PrintWriter) def loadAndRun: (String, Boolean) = { val resultObject: Class[_] = loadByName(resultObjectName) val resultValMethod: reflect.Method = resultObject getMethod "result" - def invocation = (resultValMethod.invoke(resultObject).toString, true) + // XXX if wrapperExceptions isn't type-annotated we crash scalac + val wrapperExceptions: List[Class[_ <: Throwable]] = + List(classOf[InvocationTargetException], classOf[ExceptionInInitializerError]) def onErr: Catcher[(String, Boolean)] = { case t: Throwable => beQuietDuring { bind("lastException", "java.lang.Throwable", t) } (stringFrom(t.printStackTrace(_)), false) } - catching(onErr) invokeOn( - unwrapping( - classOf[InvocationTargetException], - classOf[ExceptionInInitializerError] - ) invokeOn invocation - ) + catching(onErr) { + unwrapping(wrapperExceptions: _*) { + (resultValMethod.invoke(resultObject).toString, true) + } + } } } |