This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see StandardConditionsCowan in WG2's repo for R7RS-large.

Standard­Conditions­Cowan

cowan
2012-07-12 11:59:22
1history
source

Introduction

The procedures in this package allow programs to analyze condition objects representing exceptions reported by a Scheme implementation. Although they have the same names as their R6RS equivalents, they are meant to be implementable on top of arbitrary Scheme objects, not just records. Each predicate returns #t if the argument is an object representing the situation described for that predicate, and #f on all other objects. This package does not provide constructors for these conditions, nor any way to subclass them.

"Implies" means that if this predicate returns #t, the specified predicate also returns #t. This relationship is transitive. "Implied by" means that if the specified predicate returns #t, this predicate also returns #t.

It is an error to call an accessor procedure associated with a predicate on an object on which the predicate returns #f.

General conditions

(warning? obj)

Returns #t if obj represents a condition that does not, in principle, prohibit immediate continued execution of the program, but may interfere with the program’s execution later.

(serious-condition? obj)

Returns #t if obj represents a condition serious enough that it cannot safely be ignored.

(error? obj)

Implies serious-condition?. Implied by error-object? in the small language. Returns #t if obj represents an error, typically caused by something that has gone wrong in the interaction of the program with the external world or the user.

(violation? obj)

Implies serious-condition?. Returns #t if obj represents an violation of the language standard or a library standard, typically caused by a programming error.

(assertion-violation? obj)

Implies violation?. Returns #t if obj represents an invalid call to a procedure, either passing an invalid number of arguments, or passing an argument of the wrong type.

(non-continuable-violation? obj)

Implies violation?. This type indicates that an exception handler invoked via raise has returned.

(implementation-restriction-violation? obj)

Implies violation?. Returns #t if obj represents a violation of an implementation restriction allowed by the specification, such as being out of memory or the absence of representations for NaNs and infinities.

(lexical-violation? obj)

Implies violation?. Returns #t if obj represents a syntax violation at the level of the datum syntax.

(syntax-violation? obj)

(syntax-violation-form condition)

(syntax-violation-subform condition)

Implies violation?. Returns #t if obj represents a syntax violation. Syntax-violation-form returns an erroneous syntax object or a datum representing the code of the erroneous form. Syntax-violation-subform returns an optional syntax object or datum within the erroneous form that more precisely locates the violation. Either accessor procedure can return #f to indicate the absence of more precise information.

(undefined-violation? obj)

Implies violation?. Returns #t if obj represents an unbound identifier in the program.

Condition content

(message-condition? obj)

(condition-message condition)

Implied by error-object? in the small language. Returns #t if obj contains a string message further describing the nature of the condition to humans. Condition-message returns the string.

(irritants-condition? obj)

(condition-irritants condition)

Implied by error-object? in the small language. Returns #t if obj contains a list of objects called "irritants", typically the argument list of a procedure that detected an exception. Condition-irritants returns the list of objects.

(who-condition? obj)

(condition-who condition)

Returns #t if obj contains a symbol or string identifying the entity reporting the exception, or #f if the entity is not known. Condition-who returns the value.

I/O conditions

(i/o-error? obj)

Implies error?. Returns #t if obj represents an I/O error.

(i/o-read-error? obj)

Implies i/o-error?. Returns #t if obj represents a read error that occurred during an I/O operation.

(i/o-write-error? obj)

Implies i/o-error?. Returns #t if obj represents a write error that occurred during an I/O operation.

(i/o-invalid-position-error? obj)

(i/o-error-position condition)

Implies i/o-error?. Returns #t if obj represents an attempt to set the file position to an invalid position. I/o-error-position returns the file position that the program intended to set.

(i/o-filename-error? obj)

(i/o-error-filename condition)

Implies i/o-error?. Returns #t if obj represents an I/O error that occurred during an operation on a named file. I/o-error-filename returns the name of the file.

(i/o-file-protection-error? obj)

Implies i/o-filename-error?. Returns #t if obj represents an operation that tried to operate on a named file with insufficient access rights.

(i/o-file-is-read-only-error? obj)

Implies i/o-file-protection-error?. Returns #t if obj represents an operation tried to operate on a named read-only file under the assumption that it is writeable.

(i/o-file-already-exists-error? obj)

Implies i/o-filename-error?. Returns #t if obj represents that an operation tried to operate on an existing named file under the assumption that it did not exist.

(i/o-file-does-not-exist-error? obj)

Implies i/o-filename-error?. Returns #t if obj represents an operation that tried to operate on an non-existent named file under the assumption that it existed.

(i/o-port-error? obj)

(i/o-error-port condition)

Implies i/o-error?. Returns #t if obj contains a port with which an I/O error is associated. I/o-error-port returns the port.

(i/o-decoding-error? obj)

Implies i/o-port-error?. Returns #t if obj represents an operation for textual input from a port that encounters a sequence of bytes that cannot be translated into a character or string by the input direction of the port’s transcoder.

(i/o-encoding-error? obj)

(i/o-encoding-error-char condition)

Implies i/o-port-error?. Returns #t if obj represents an operation for textual output to a port encounters a character that cannot be translated into bytes by the output direction of the port's transcoder. I/o-encoding-error-char returns the character that could not be encoded.

Numeric conditions

(no-infinities-violation? obj)

Implies implementation-restriction-violation?. Returns #t if obj represents an arithmetic operation that is specified to return an infinity on a Scheme implementation that is not able to represent the infinity.

(no-nans-violation? obj)

Implies implementation-restriction-violation?. Returns #t if obj represents an arithmetic operation that is specified to return a NaN on a Scheme implementation that is not able to represent the NaN.