Skip to main content

error

error Condition Type

Class Precedence List:

error, serious-condition, condition, t

Description:

The type error consists of all conditions that represent errors.

Expanded Reference: error (Condition Type)

The Error Condition Type

error is a condition type representing serious conditions that generally require intervention. It is a subtype of serious-condition. When an error condition is signaled and not handled, the debugger is entered.

(subtypep 'error 'serious-condition)

=> T
=> T

Type Checking with error

All error conditions are of type error.

(typep (make-condition 'simple-error :format-control "oops") 'error)

=> T
(typep (make-condition 'type-error :datum 1 :expected-type 'string) 'error)

=> T

Catching All Errors

handler-case with an error clause catches any condition of type error, including all subtypes.

(handler-case (error 'division-by-zero)
(error (c)
(format nil "Caught an error of type ~S" (type-of c))))

=> "Caught an error of type DIVISION-BY-ZERO"

Standard Error Subtypes

The standard defines many subtypes of error, including type-error, cell-error, arithmetic-error, stream-error, parse-error, and others.

(subtypep 'type-error 'error)

=> T
=> T
(subtypep 'arithmetic-error 'error)

=> T
=> T