Open a REPL at the stack frame of an error (for debugging)?

When an eror happens, we get a stack trace. But I realized that for debugging it could be extremely useful to ask that the REPL stay at the stack frame where the error happened rather than returning immeditaly to the top level.

Is this possible?

If the REPL stayed at the local stack frame, we could interactively query variables, but do much more as well. For example, we could interactively call some function on a variable (e.g. to ensure that the sum of an array is 1, if it is supposed to be that),

or even interactively set a variable to some value or function value - e.g. in a long running computation where we forgot one line, just interactively add the missing step.

Then give a command to continue (or throw to the top level, depending)

1 Like