Example usage

Consider the following definitions:

(define (foo x)
  (if (not (symbol? x))
      (error "not a symbol"))
  (cons x x))

(define (bar y)
    (foo y)

The bar procedure calls foo procedure in a context in which errors are caught. If foo signals a condition (as it will if its argument is not a symbol), then bar catches the condition and returns bar's argument instead of whatever foo returns.

Example 12-1. Examples using exception handlers

(bar 'x) (x . x)

(bar 3) 3