Next: , Previous: , Up: iklib syntaxes   [Index]


6.8.9 Blocking raised exceptions

Sometimes we want to block raised exceptions, for example when we are already handling a previously raised exception.

Syntax: with-blocked-exceptions ?thunk
Syntax: with-blocked-exceptions ?exception-retvals-maker ?thunk

Evaluate ?thunk and return its return values.

When used with one argument: if ?thunk raises an exception, return the raised object.

When used with two arguments: if ?thunk raises an exception, apply the procedure ?exception-retvals-maker to the raised object and return its return values. Exceptions raised by ?exception-retvals-maker are not blocked.

Usage examples:

(import (vicare))

(with-blocked-exceptions
  (lambda ()
    (raise 99)))
⇒ 99

(with-blocked-exceptions
    (lambda (E)
      (values E 1 2 3))
  (lambda ()
    (raise 99)))
⇒ 99 1 2 3