Skip to content

Resume in the catch block after breaking on a caught exception - #428

Open
KristofferC wants to merge 1 commit into
masterfrom
kc/continue-after-caught-throw
Open

KristofferC wants to merge 1 commit into
masterfrom
kc/continue-after-caught-throw

Conversation

@KristofferC

Copy link
Copy Markdown
Member

With break_on(:throw) (bp on throw), the debugger stops at every throw, including throws the code catches. After such a stop every stepping command was refused with "Cannot step after breaking on error", so the only option was to quit the session:

function caught_twice(xs)
    n = 0
    for x in xs
        v = try
            parse(Int, x)
        catch
            -1
        end
        n += v
    end
    return n
end
break_on(:throw); @enter caught_twice(["a", "1", "b"])
# c → stops at the throw for "a"; c / n → "Cannot step after breaking on error"

Now, when an interpreted frame catches the exception the session stopped for, a stepping command unwinds into that handler with JuliaInterpreter.unwind_exception:

  • c continues from the handler (in the example: on to the throw for "b", then to the end),
  • the other stepping commands stop at the start of the catch block.

Stepping after an uncaught error is still refused. The exception is kept in a new DebuggerState field, error_stopped_for. unwind_exception exists in all supported JuliaInterpreter versions.

Tests: continuing past caught throws (fails without the change), and the refusal after an uncaught error.

🤖 Generated with Claude Code

With `break_on(:throw)`, the debugger stops at every throw, including throws
that the code catches. After such a stop, every stepping command was refused
with "Cannot step after breaking on error", so the session could only be quit.

When an interpreted frame catches the exception the session stopped for,
a stepping command now unwinds into that handler (`JuliaInterpreter.unwind_exception`):
`c` continues from there, the other commands stop at the start of the `catch`
block. Stepping after an uncaught error is still refused. The exception is kept
in the new `DebuggerState` field `error_stopped_for`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant