|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
with-error-handler. That is,
with-error-handlerreturns whatever value(s) handler returns.
If handler signals an error, it will be handled by the
handler installed when
The dynamic environment where handler is executed is
the same as the error occurs. If
dynamic-wind is used
in thunk, its after method is called after handler
has returned, and before
The behavior of
with-error-handler can be
described in the form of Scheme code shown below,
using the low-level mechanism (See section 6.16.4 Low-level exception mechanism).
Note that the actual function is built in VM, using lighter
mechanisms (similar to "one-shot continuation", 1CC).
;; conceptual implementation of with-error-handler (define (with-error-handler handler thunk) (call/cc (lambda (cont) (let* ((prev-handler (current-exception-handler)) (with-exception-handler (lambda (exn) (if (error? exn) (with-exception-handler (lambda (err) (prev-handler err)) (lambda () (call-with-values (handler exn) cont))) (prev-handler exn))) thunk))))))