Skip to content

Capture exceptions and expose them to the REPL #289

@lihaoyi

Description

@lihaoyi

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.

Currently it just prints

haoyi-static-analysis@ while(true)()
^C
Interrupted!

When you interrupt it. We could instead assign it to some value

haoyi-static-analysis@ while(true)()
^C
val res12: InterruptedException = ...

Which would both show the user that it was interrupted, and let them dig deeper if they wished to

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions