- with-exception-handler handler thunkprocedure
It is an error if handler does not accept one argument. It is also an error if thunk does not accept zero arguments. The with-exception-handler procedure returns the results of invoking thunk. Handler is installed as the current exception handler in the dynamic environment used for the invocation of thunk.
(call-with-current-continuation (lambda (k) (with-exception-handler (lambda (x) (display "condition: ") (write x) (newline) (k 'exception)) (lambda () (+ 1 (raise 'an-error)))))) ==> exception and prints "condition: an-error" (with-exception-handler (lambda (x) (display "something went wrong\n")) (lambda () (+ 1 (raise 'an-error))))prints "something went wrong" After printing, the second example then raises another exception.