diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-27 18:55:24 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-27 18:55:24 +0000 |
commit | 4b8be5d8bec86358276407d6521c41702ccda835 (patch) | |
tree | a0637feb289cb6a065150683a8e346c559c18af4 /src | |
parent | b036f6fe74373bee058cf6cf85e482dc75c09fd9 (diff) | |
download | scala-4b8be5d8bec86358276407d6521c41702ccda835.tar.gz scala-4b8be5d8bec86358276407d6521c41702ccda835.tar.bz2 scala-4b8be5d8bec86358276407d6521c41702ccda835.zip |
Added interpreter binding for "lastException" w...
Added interpreter binding for "lastException" which caches the last
thrown exception. So you can say e.g. lastException.printStackTrace
whenever you like.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/Interpreter.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 123ed92a66..206067efd8 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -772,7 +772,11 @@ class Interpreter(val settings: Settings, out: PrintWriter) } (reflectionUnwrapper either pair) match { - case Left(e) => (stringFrom(unwrap(e).printStackTrace(_)), false) + case Left(e) => + val unwrapped = unwrap(e) + beQuietDuring { bind("lastException", "java.lang.Throwable", unwrapped) } + + (stringFrom(unwrapped.printStackTrace(_)), false) case Right((res, success)) => (res, success) } } |