A handled runtime error (an exception) can cause a pause when debugging, like a breakpoint.
A handled runtime error is an error that occurs within a try block. It would not normally cause any break in the action, because AppleScript will continue execution in the on error
clause, or (if there is no on error
clause) after the try block. But Script Debugger can optionally pause when it detects a handled runtime exception.
An unhandled runtime error causes execution to abort entirely, so there is no question about pausing there — the script will do more than pause, it will stop.
To pause at handled runtime errors:
Optionally, you can add an Exceptions button to the script window’s toolbar that toggles breaking on exceptions (and reflects the state of that toggle).
If Break on Exceptions is checked and a handled runtime error is encountered while debugging, execution pauses much as if this were a breakpoint, just before the exception is actually thrown. Variables and expressions are evaluated at that point. A red arrow marks the line where the error occurs.
To learn what the error was, while paused at the error:
Look at the status bar; it contains the error message, as is usual for errors.
Choose Script > Show Last Error; or, click the red arrow. This summons the normal error dialog.
Optionally, you can add a Show Last Error button to the script window’s toolbar.
Even if Break on Exceptions is unchecked, and a handled runtime error does not cause a pause, you can still learn, at the first pause after the error is encountered, where the error was (the red arrow is still present) and what the error was (choose Script > Show Last Error, or click the red arrow).
Once you resume execution of the script, the exception mark is removed (and Show Last Error will no longer recover it).