Common Lisp the Language, 2nd Edition

Next: General Error-Signaling Functions Up: Common Lisp the Language Previous: Accessing Directories

# 24. Errors

Errors may be signaled for a variety of reasons. Many built-in Common Lisp functions may signal an error when given incorrect arguments. Other functions, described in this chapter, may be called by user programs for the purpose of signaling an error.

When an error is signaled, it is handled in an implementation-dependent way. It is expected that each implementation of Common Lisp will provide an interactive debugger that prints the error message along with suitable contextual information such as which function detected the error. The user may interact with the debugger to examine or modify the state of the program in various ways, including abandoning the current computation (``aborting to top level'') and continuing from the error. What ``continuing'' means depends on how the error is signaled; the details of this are specified below for each error-signaling function.

An implementation may also choose to provide means (such as the `errset` special form in MacLisp) for a program to trap all errors and prevent the debugger from stepping in for certain errors.

Rationale: Error handling of adequate flexibility and power for all systems written in Common Lisp appears to require a complex error classification system. Experience with several error-handling systems in such dialects as MacLisp and Lisp Machine Lisp indicates that further experimentation is needed in this area; it is too early to define a standard error-handling mechanism. Therefore Common Lisp provides standard ways to signal errors, but no standard ways to handle errors. Of course a complete Lisp system requires error-handling mechanisms, but many useful portable programs do not require them. It is expected that a future revision of Common Lisp will address the problem of portable error-handling mechanisms.

X3J13 voted in June 1988 (CONDITION-SYSTEM) to adopt a proposal for a Common Lisp Condition System. This was the result of the research and experimentation alluded to in the preceding paragraph. Conditions subsume and generalize the notion of errors. The condition system also provides means for handling conditions (of which errors are a special case) and for restarting a computation after a condition has been signaled. See chapter 29.

Compatibility note: What is here called ``continuing,'' Lisp Machine Lisp calls ``proceeding'' from an error.

In the new terminology introduced in chapter 29, what Lisp Machine Lisp called ``proceeding'' would be called ``restarting,'' and ``continuing'' refers to the particular restart named `continue`.

- General Error-Signaling Functions
- Specialized Error-Signaling Forms and Macros
- Special Forms for Exhaustive Case Analysis

Next: General Error-Signaling Functions Up: Common Lisp the Language Previous: Accessing Directories