20 Errors

An error object contains information that can be used to describe an error that occured in the klisp system. The interpreter will pass an error object to an error continuation whenever it needs to signal that an error occured while executing a program or evaluating an expression.

An error object contains a message describing the situation and a (possibly empty) list of objects, called its irritants, that provide some context or additional info depending on the error condition. The error type is encapsulated.

Notice that unlike in most other languages, the error object in klisp isn’t used to classify the error in error handlers, the error continuation being passed the error object is used for that. The error object is used only to convey additional info, not the type of error.

SOURCE NOTE: The type of object passed to the error continuation is not specified in the Kernel Report. This type was inspired by r7rs scheme.

— Applicative: error-object? (error-object? . objs)

The primitive type predicate for type error. error-object? returns true iff all the objects in objects are of type error.

— Applicative: error (error msg . objs)

Create an error object with message msg and irritants the list of objects objs and then send that error object to the error continuation. This is the recommended way to signal an error in klisp.

— Applicative: raise (raise obj)

Send obj to the error continuation. obj needs not be an error object, any kind of object can be sent to the error continuation (but that’s not recommended!).

— Applicative: error-object-message (error-object-message error)

Applicative error-object-message extracts the message of error.

— Applicative: error-object-irritants (error-object-irritants error)

Applicative error-object-irritants extracts the irritants of error.