Go to the first, previous, next, last section, table of contents.


Exceptions

primitive: catch key thunk handler
Invoke thunk in the dynamic context of handler for exceptions matching key. If thunk throws to the symbol key, then handler is invoked this way:

(handler key args ...)

key is a symbol or #t.

thunk takes no arguments. If thunk returns normally, that is the return value of catch.

Handler is invoked outside the scope of its own catch. If handler again throws to the same key, a new handler from further up the call chain is invoked.

If the key is #t, then a throw to any symbol will match this call to catch.

primitive: throw key &rest args ...
Invoke the catch form matching key, passing args to the handler.

key is a symbol. It will match catches of the same symbol or of #t.

If there is no handler at all, an error is signaled.

procedure: error msg args ...
Raise an error with key misc-error and a message constructed by displaying msg and writing args.

primitive: scm-error key subr message args data
Raise an error with key key. subr can be a string naming the procedure associated with the error, or #f. message is the error message string, possibly containing %S and %s escapes. When an error is reported, these are replaced by formating the corresponding members of args: %s formats using display and %S formats using write. data is a list or #f depending on key: if key is system-error then it should be a list containing the Unix errno value; If key is signal then it should be a list containing the Unix signal number; otherwise it will usually be #f.

primitive: strerror errno
Returns the Unix error message corresponding to errno, an integer.

syntax: false-if-exception expr
Returns the result of evaluating its argument; however if an exception occurs then #f is returned instead.

It is traditional in Scheme to implement exception systems using call-with-current-continuation, but his has not been done, for performance reasons. The implementation of call-with-current-continuation is a stack copying implementation. This allows it to interact well with ordinary C code. Unfortunately, a stack-copying implementation can be slow -- creating a new continuation involves a block copy of the stack.

Instead of using call-with-current-continuation, the exception primitives are implemented as built-ins that take advantage of the upward only nature of exceptions.


Go to the first, previous, next, last section, table of contents.