Next: Cleaning Up from Nonlocal Exits, Previous: catch
and throw
—Explicit Nonlocal Exits, Up: Nonlocal Exits [Index]
unwind-protect
function, cleanup expressions
condition-case
function, recover control
When Emacs Lisp attempts to evaluate a form that, for some reason, cannot be evaluated, it signals an error. When an error is signaled, Emacs’s default reaction is to print an error message and terminate execution of the current command.
In complicated programs, simple termination may not be what you want. In such cases, you would use the function unwind-protect to establish cleanup expressions to be evaluated in case of error.
Occasionally, you may wish the program to continue execution despite an error in a subroutine. In these cases, you would use the function condition-case to establish error handlers to recover control in case of error.
Resist the temptation to use error handling to transfer control from one part
of the program to another; use catch
and throw
instead.