Next: , Previous: , Up: restarts   [Index]


1.18.3 Ignoring signalled conditions of type &error

Syntax: ignore-errors ?body0 ?body

Install a handler for conditions of type &error, then evaluate the body forms; the handler is installed using handler-case. If the body performs a normal return: its return values become the return values of ignore-errors. If the body signals a condition of type &error: two values are returned, #f and the signalled condition object.

Usage examples:

(import (vicare)
  (only (vicare checks)
        with-result
        add-result))

;;no condition
(with-result
  (ignore-errors
    (add-result 'body)
    1))
⇒ (1 (body))

(internal-body ;;signalled condition

(define (doit C)
  (with-result
    (handler-case
        ((&error   (lambda (E)
                     (add-result 'error-handler)
                     1))
         (&warning (lambda (E)
                     (add-result 'warning-handler)
                     2)))
      (receive (A B)
          (ignore-errors
            (add-result 'body-begin)
            (signal C)
            (add-result 'body-normal-return))
        (values A (and (error? B) 99))))))

  (doit (make-error))
  ⇒ (#f 99 (body-begin))

  (doit (make-warning))
  ⇒ (2 (body-begin warning-handler))

  #| end of body |# )