Skip to content

rnrs exceptions

The (rnrs exceptions (6)) library provides functionality related to signaling and handling exceptional situations. This functionality re-exports Guile’s core exception-handling primitives. See Exceptions, for a full discussion. See SRFI-34 - Exception handling for programs, for a similar pre-R6RS facility. In Guile, SRFI-34, SRFI-35, and R6RS exception handling are all built on the same core facilities, and so are interoperable.

Scheme Procedure: with-exception-handler handler thunk

See Raising and Handling Exceptions, for more information on with-exception-handler.

Scheme Syntax: guard (variable clause1 clause2 ...) body

Evaluates the expression given by body, first creating an ad hoc exception handler that binds a raised exception to variable and then evaluates the specified clauses as if they were part of a cond expression, with the value of the first matching clause becoming the value of the guard expression (see Simple Conditional Evaluation). If none of the clause’s test expressions evaluates to #t, the exception is re-raised, with the exception handler that was current before the evaluation of the guard form.

For example, the expression

emacs-lisp
(guard (ex ((eq? ex 'foo) 'bar) ((eq? ex 'bar) 'baz)) 
  (raise 'bar))

evaluates to baz.

Scheme Procedure: raise obj

Equivalent to core Guile (raise-exception obj). See Raising and Handling Exceptions. (Unfortunately, raise is already bound to a different function in core Guile. See Signals.)

Scheme Procedure: raise-continuable obj

Equivalent to core Guile (raise-exception obj #:continuable? #t). See Raising and Handling Exceptions.