Next: , Previous: , Up: Errors—Unintentional Nonlocal Exits   [Index]


F.6.2.2 Error Processing—Error Debugging

Error Processing Concepts

When an ‘error’ is signaled, signal searches for an active handler for the ‘error’ (next).

handler

a sequence of Lisp expressions designated to be executed if an error happens in part of the Lisp program.

If the ‘error’ has an applicable handler, the handler is executed, and control resumes following the handler. The handler executes in the environment of the condition-case that established it; all functions called within that condition-case have already been exited, and the handler cannot return to them.

If there is no applicable handler for the ‘error’, it terminates the current command and returns control to the editor command loop. The command loop’s handler uses the ‘error’ symbol and associated data to print an error message.

The Debugger

An error that has no explicit handler may call the Lisp debugger. The debugger is enabled if the variable debug-on-error is non-‘nil’.

Unlike error handlers, the debugger runs in the environment of the ‘error’, so that you can examine values of variables precisely as they were at the time of the ‘error’.

Variable: command-error-function

This variable, if non-‘nil’, specifies a function to use to handle errors that return control to the Emacs command loop. The function should take three arguments:

  1. data’, a list of the same form that condition-case would bind to its variable;
  2. context’, a string describing the situation in which the error occurred, or (more often) ‘nil’;
  3. caller’, the Lisp function which called the primitive that signaled the error.

Next: Using condition-case to Trap and Handle Errors with Handlers, Previous: Error Signaling, Up: Errors—Unintentional Nonlocal Exits   [Index]