[plt-scheme] Catch all exceptions

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Aug 30 13:58:01 EDT 2004

On Aug 30, Dmitriy.Zavin at infineon.com wrote:
> I was wondering, is there a catch-all type mechanism in mzscheme to
> catch all exceptions?
> 
> I want something like
> 	(with-handlers ([any-exn? (lambda (exn)  (write "foo"))])
> 		(my-proc))
> 
> Is something like tha doable?

Yes -- use the above with

  (define (any-exn? exn) #t)

A common idiom is to use `void' instead -- it is a function that
always returns the void value, which is not #f so it is true.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.