(rnrs exceptions (6)) library provides functionality related
to signaling and handling exceptional situations. This functionality is
similar to the exception handling systems provided by Guile’s core
library See Exceptions, and by the SRFI-18 and SRFI-34
modules—See SRFI-18 Exceptions, and SRFI-34,
respectively—but there are some key differences in concepts and
A raised exception may be continuable or non-continuable.
When an exception is raised non-continuably, another exception, with the
&non-continuable, will be raised when the
exception handler returns locally. Raising an exception continuably
captures the current continuation and invokes it after a local return
from the exception handler.
Like SRFI-18 and SRFI-34, R6RS exceptions are implemented on top of
catch forms, and use custom
“throw keys” to identify their exception types. As a consequence,
catch form can handle exceptions thrown by these APIs,
but the reverse is not true: Handlers registered by the
with-exception-handler procedure described below will only be
called on exceptions thrown by the corresponding
Installs handler, which must be a procedure taking one argument,
as the current exception handler during the invocation of thunk, a
procedure taking zero arguments. The handler in place at the time
with-exception-handler is called is made current again once
either thunk returns or handler is invoked after an
exception is thrown from within thunk.
This procedure is similar to the
provided by Guile’s code library; (see Throw Handlers).
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
(see Conditionals). If none of the clause’s test expressions
#t, the exception is re-raised, with the exception
handler that was current before the evaluation of the
For example, the expression
(guard (ex ((eq? ex 'foo) 'bar) ((eq? ex 'bar) 'baz)) (raise 'bar))
Raises a non-continuable exception by invoking the currently-installed
exception handler on obj. If the handler returns, a
&non-continuable exception will be raised in the dynamic context
in which the handler was installed.
Raises a continuable exception by invoking currently-installed exception handler on obj.