----- Original Message ----
> From: Robby Findler <ro...@eecs.northwestern.edu>

> (with-handlers ([exn:fail? (lambda (exn)  put-specified-default-here)])
>     try-something-here)

That's the fellow!

Here's a little convenience macro I defined:

(define-syntax catch-errors
  (syntax-rules ()
          ((catch-all error-value body ...)
           (with-handlers ([exn:fail? (lambda (exn) error-value)])
             body ...))))

(catch-errors "Oops" (/ 1 0)) ; "Oops"
(catch-errors "Oops" (/ 6 3)) ; 2
(catch-errors "Oops" (/ 6 3) (/ 16 2)) ; 8



      
_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to