Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: R6RS Standard Libraries   [Contents][Index]


7.6.2.13 rnrs conditions

The (rnrs condition (6)) library provides forms and procedures for constructing new condition types, as well as a library of pre-defined condition types that represent a variety of common exceptional situations. Conditions are records of a subtype of the &condition record type, which is neither sealed nor opaque. See R6RS Records.

Conditions may be manipulated singly, as simple conditions, or when composed with other conditions to form compound conditions. Compound conditions do not “nest”—constructing a new compound condition out of existing compound conditions will “flatten” them into their component simple conditions. For example, making a new condition out of a &message condition and a compound condition that contains an &assertion condition and another &message condition will produce a compound condition that contains two &message conditions and one &assertion condition.

The record type predicates and field accessors described below can operate on either simple or compound conditions. In the latter case, the predicate returns #t if the compound condition contains a component simple condition of the appropriate type; the field accessors return the requisite fields from the first component simple condition found to be of the appropriate type.

This library is quite similar to the SRFI-35 conditions module (see SRFI-35). Among other minor differences, the (rnrs conditions) library features slightly different semantics around condition field accessors, and comes with a larger number of pre-defined condition types. The two APIs are not currently compatible, however; the condition? predicate from one API will return #f when applied to a condition object created in the other.

Condition Type: &condition
Scheme Procedure: condition? obj

The base record type for conditions.

Scheme Procedure: condition condition1 ...
Scheme Procedure: simple-conditions condition

The condition procedure creates a new compound condition out of its condition arguments, flattening any specified compound conditions into their component simple conditions as described above.

simple-conditions returns a list of the component simple conditions of the compound condition condition, in the order in which they were specified at construction time.

Scheme Procedure: condition-predicate rtd
Scheme Procedure: condition-accessor rtd proc

These procedures return condition predicate and accessor procedures for the specified condition record type rtd.

Scheme Syntax: define-condition-type condition-type supertype constructor predicate field-spec ...

Evaluates to a new record type definition for a condition type with the name condition-type that has the condition type supertype as its parent. A default constructor, which binds its arguments to the fields of this type and its parent types, will be bound to the identifier constructor; a condition predicate will be bound to predicate. The fields of the new type, which are immutable, are specified by the field-specs, each of which must be of the form:

(field accessor)

where field gives the name of the field and accessor gives the name for a binding to an accessor procedure created for this field.

Condition Type: &message
Scheme Procedure: make-message-condition message
Scheme Procedure: message-condition? obj
Scheme Procedure: condition-message condition

A type that includes a message describing the condition that occurred.

Condition Type: &warning
Scheme Procedure: make-warning
Scheme Procedure: warning? obj

A base type for representing non-fatal conditions during execution.

Condition Type: &serious
Scheme Procedure: make-serious-condition
Scheme Procedure: serious-condition? obj

A base type for conditions representing errors serious enough that cannot be ignored.

Condition Type: &error
Scheme Procedure: make-error
Scheme Procedure: error? obj

A base type for conditions representing errors.

Condition Type: &violation
Scheme Procedure: make-violation
Scheme Procedure: violation?

A subtype of &serious that can be used to represent violations of a language or library standard.

Condition Type: &assertion
Scheme Procedure: make-assertion-violation
Scheme Procedure: assertion-violation? obj

A subtype of &violation that indicates an invalid call to a procedure.

Condition Type: &irritants
Scheme Procedure: make-irritants-condition irritants
Scheme Procedure: irritants-condition? obj
Scheme Procedure: condition-irritants condition

A base type used for storing information about the causes of another condition in a compound condition.

Condition Type: &who
Scheme Procedure: make-who-condition who
Scheme Procedure: who-condition? obj
Scheme Procedure: condition-who condition

A base type used for storing the identity, a string or symbol, of the entity responsible for another condition in a compound condition.

Condition Type: &non-continuable
Scheme Procedure: make-non-continuable-violation
Scheme Procedure: non-continuable-violation? obj

A subtype of &violation used to indicate that an exception handler invoked by raise has returned locally.

Condition Type: &implementation-restriction
Scheme Procedure: make-implementation-restriction-violation
Scheme Procedure: implementation-restriction-violation? obj

A subtype of &violation used to indicate a violation of an implementation restriction.

Condition Type: &lexical
Scheme Procedure: make-lexical-violation
Scheme Procedure: lexical-violation? obj

A subtype of &violation used to indicate a syntax violation at the level of the datum syntax.

Condition Type: &syntax
Scheme Procedure: make-syntax-violation form subform
Scheme Procedure: syntax-violation? obj
Scheme Procedure: syntax-violation-form condition
Scheme Procedure: syntax-violation-subform condition

A subtype of &violation that indicates a syntax violation. The form and subform fields, which must be datum values, indicate the syntactic form responsible for the condition.

Condition Type: &undefined
Scheme Procedure: make-undefined-violation
Scheme Procedure: undefined-violation? obj

A subtype of &violation that indicates a reference to an unbound identifier.


Next: , Previous: , Up: R6RS Standard Libraries   [Contents][Index]