In error.diesel:
The
handle_system_errors
function executes its argument
closure. Any Diesel ``system errors'' (e.g., error or exit
calls) caused during evaluation of the closure are caught and
suppressed (after the trap into the debugger returns). The
boolean return value indicates whether an error was suppressed.
The unwind_protect
function allows a ``clean up'' closure to be
executed whenever control returns through the unwind_protect
function call, either normally, via a non-local return, or via a
Diesel ``system error.'' unwind_protect
first invokes its cl
closure argument. When control returns from this invocation, the
on_return
closure is invoked. If the on_return
closure returns
normally, the returning of the cl closure is resumed: if the cl
closure returned normally, the result of this closure is returned
normally as the result of the unwind_protect
function; otherwise
it continues to throw whatever exception or system error the body
did. If the on_return
closure returns abnormally, either via a
non-local return or a system error, then this result supercedes the
original suspended result of the cl closure. (unwind_protect
is
similar to the like-named construct in Common Lisp.)
The on_error
function allows a ``clean up'' closure to be executed
whenever control returns through the on_error
function call
abnormally, either via a non-local return or via a Diesel ``system
error.'' on_error
first invokes its cl closure argument. If
control returns normally from cl, then on_error
returns normally
the result of this closure, without invoking its on_error
closure.
If, on the other hand, control returns from cl either via a
non-local return or a system error, the on_error
closure is
invoked. If this closure completes normally, the abnormal returning
of the cl closure is resumed (either continuing the non-local
return or the system error raised by cl). If the on_error
closure returns abnormally, either via a non-local return or a
system error, then this result supercedes the original suspended
abnormal result of the cl closure. on_error
is like
unwind_protect
, except that the on_error
block is only run if
the cl block has an abnormal result.