You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EDIT: Original issue was for ThreadDeath, but this will be useful for any exception
This can be exposed to the REPL as a value, and would be useful for a variety of reasons:
You may want to know "how far" execution went before you interrupted it. Inspecting the stack trace would give you some indication of "where" in the executed code it had reached.
A prime case of interrupting code is when it infinite-loops; in such a case you'd like to know where the infinite loop is! Since that's where the program is spending "all" its time, the stack trace (perhaps repeated once or twice) should give a very good indication of where the program is getting stuck
If the program is blocked/deadlocked on something indefinitely when you interrupt it (e.g. out of frustration) the stack trace will point directly to the offending line of code.
Actually this might not be unique to ThreadDeath; any exception that gets thrown should be made available as a val, as sometimes they contain useful metadata e.g. FastParse's ParseErrors or Ammonite-Ops's ShelloutExceptions.
By making these uncaught exceptions available to the shell session by default, we could save a lot of annoying re-running-code-with-try-catch during interactive development and exploration
changed the title
Capture stack trace of ThreadDeath exception when execution is interruptedDec 13, 2015
Turn out the normal REPL has a mutable lastException: Throwable definition. This is halfway there, but isn't ideal: you still need to cast the Throwable into the correct type before being able to manipulate it usefully. The REPL should already know what the type is, and by exposing it as a val of the correct type, you won't need to do the casting yourself.