Previous: , Up: Exceptions   [Contents][Index]


4.6.2 Raising and handling exceptions

The (hoot errors) module provides procedures for raising and handling exceptions.

Procedure: raise exception

Raise the non-continuable exception exception by invoking the current exception handler.

Procedure: raise-continuable exception

Raise the continuable exception exception by invoking the current exception handler.

Procedure: raise-exception exception [#:continuable? #f]

Raise the exception exception by invoking the current exception handler. When continuable? is #t, the raised exception is continuable.

Procedure: with-exception-handler handler thunk [#:unwind? #f]

Call thunk, a procedure of zero arguments, in a context where handler, a procedure of one argument, is the current exception handler. If an exception is raised then handler will be called with the exception obect.

When unwind? is #t, the stack will be unwound before handler is called. The default behavior is not to unwind. When the stack is not unwound, it is up to handler to properly manage control flow. Control is allowed to fallthrough handler and resume from where the exception was raised only if the raised exception is continuable. For non-continuable exceptions, handler should abort to some prompt (See Control) to escape the exception handling context.