Errors are a type of non-local exit; when a form can not be evaluated properly an error is normally signalled. If an error-handler has been installed for that type of error control is unwound back to the handler and evaluation continues. If there is no suitable handler control is passed back to the event loop of the most-recent recursive edit and a suitable error message is printed.
error-message
(a string) which is the error message to be printed.
data is a list of objects which are relevant to the error -- they will be made available to any error-handler or printed with the error message otherwise.
(signal 'void-value '(some-symbol))
error--> Value as variable is void: some-symbol
signal. If its value
is either t or a list containing the error-symbol to
signal as one of its elements, the Lisp debugger is entered.
When the debugger exits the error is signalled as normal.
When you expect an error to occur and need to be able to regain control
afterwards the error-protect form can be used.
error-protect evaluates the body-form with error
handlers in place.
Each of the error-handlers is a list whose car is a symbol defining the type of error which this handler catches. The cdr of the list is a list of forms to be evaluated sequentially when the handler is invoked.
While the forms of the error handler are being evaluated the variable
error-info is bound to the value (error-symbol . data)
(these were the arguments to the signal form which caused the
error).
The special value, the symbol error, in the car of one of the
error-handlers will catch all types of errors.
(error-protect
(signal 'file-error '("File not found" "/tmp/foo"))
(file-error
error-info)
(error
(setq x z))) ;Default handler
=> (file-error "File not found" "/tmp/foo")
Go to the first, previous, next, last section, table of contents.