Library (rnrs conditions (6))

The section describes (rnrs conditions (6))library for creating and inspecting condition types and values. A condition value encapsulates information about an exceptional situation.

Function condition condition ...

[R6RS] The condition procedure returns a condition object with the components of the conditions as its components, in the same order. The returned condition is compound if the total number of components is zero or greater than one. Otherwise, it may be compound or simple.

Function simple-condition condition

[R6RS] The simple-conditions procedure returns a list of the components of condition, in the same order as they appeared in the construction of condition.

Function condition? obj

[R6RS] Returns #t if obj is a (simple or compound) condition, otherwise returns #f.

Function condition-predicate rtd

[R6RS] Rtd must be a record-type descriptor of a subtype of &condition. The condition-predicate procedure returns a procedure that takes one argument. This procedure returns #t if its argument is a condition of the condition type represented by rtd, i.e., if it is either a simple condition of that record type (or one of its subtypes) or a compound conditition with such a simple condition as one of its components, and #f otherwise.

Function condition-accessor rtd proc

[R6RS] Rtd must be a record-type descriptor of a subtype of &condition. Proc should accept one argument, a record of the record type of rtd. The condition-accessor procedure returns a procedure that accepts a single argument, which must be a condition of the type represented by rtd. This procedure extracts the first component of the condition of the type represented by rtd, and returns the result of applying proc to that component.

Macro define-condition-type condition-type supertypes constructor predicate field-spec ...

[R6RS] Condition-type, supertypes, constructor, and predicate must all be identifiers. Each field-spec must be of the form

(_field_ _accessor_)

where both field and accessor must be identifiers.

The define-condition-type form expands into a record-type definition for a record type condition-type. The record type will be non-opaque, non-sealed, and its fields will be immutable. It will have supertype has its parent type. The remaining identifiers will be bound as follows:

Standard condition types

Hierarchy of standard condition types:

+ &condition
    + &warning
    + &serious
          + &error
          + &violation
                + &assertion
                + &non-continuable
                + &implementation-restriction
                + &lexical
                + &syntax
                + &undefined
    + &message
    + &irritants
Condition Type &message

[R6RS] It carries a message further describing the nature of the condition to humans.

Condition Type &warning

[R6RS] This type describes conditions that do not, in principle, prohibit immediate continued execution of the program, but may interfere with the program's execution later.

Condition Type &serious

[R6RS] This type describes conditions serious enough that they cannot safely be ignored. This condition type is primarily intended as a supertype of other condition types.

Condition Type &error
Function make-error
Function error? obj

[R6RS] This type describes errors, typically caused by something that has gone wrong in the interaction of the program with the external world or the user.

Condition Type &violation

[R6RS] This type describes violations of the language standard or a library standard, typically caused by a programming error.

Condition Type &assertion

[R6RS] This type describes an invalid call to a procedure, either passing an invalid number of arguments, or passing an argument of the wrong type.

Condition Type &irritants

[R6RS] Irritants should be a list of objects. This condition provides additional information about a condition, typically the argument list of a procedure that detected an exception. Conditions of this type are created by the error and assertion-violation procedures.

Condition Type &who

[R6RS] Who should be a symbol or string identifying the entity reporting the exception. Conditions of this type are created by the errorand assertion-violation procedures, and the syntax-violationprocedure.

Condition Type &non-continuable

[R6RS] This type indicates that an exception handler invoked via raise has returned.

[R6RS] This type describes a violation of an implementation restriction allowed by the specification, such as the absence of representations for NaNs and infinities.

Condition Type &lexical

[R6RS] This type describes syntax violations at the level of the datum syntax.

Condition Type &syntax

[R6RS] This type describes syntax violations. Form should be the erroneous syntax object or a datum representing the code of the erroneous form. Subform should be an optional syntax object or datum within the erroneous form that more precisely locates the violation. It can be #f to indicate the absence of more precise information.

Condition Type &undefined

[R6RS] This type describes unbound identifiers in the program.