[plt-scheme] Catch all exceptions

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Aug 30 15:25:12 EDT 2004

Probably you want

  (define (my-exn? exn)  (or (exn:user? exn) (exn:io? exn)))

if those are the two kinds of exceptions you want to catch.

Robby

At Mon, 30 Aug 2004 12:19:22 -0700, Dmitriy.Zavin at infineon.com wrote:
> Well, I guess I have to see what exceptions my extension can throw, and only grab those. It's 
> for my little RPC, where the server talks to the hardware through my driver (which can throw 
> exceptions). The exceptions are caught, and print-convert'd across a socket and have it 
> raised on the other side. It works right now for all exceptions, but now that you mention it 
> I'll have to isolate the ones that can occur in the driver, and let local exceptions be 
> handled by the server.
> 
> So would my test look like this?
> 
> (define (my-exn? exn)
> 	(cond ((eq? exn 'exn:user) #t)
> 		 ((eq? exn 'exn:io) #t)
> 		 (else #f)))
> 
> 
> 
>  >-----Original Message-----
>  >From: plt-scheme-admin at list.cs.brown.edu 
>  >[mailto:plt-scheme-admin at list.cs.brown.edu] On Behalf Of Robby Findler
>  >Sent: Monday, August 30, 2004 12:07 PM
>  >To: Jens Axel Søgaard
>  >Cc: plt-scheme at list.cs.brown.edu
>  >Subject: Re: [plt-scheme] Catch all exceptions
>  >
>  >
>  >  For list-related administrative tasks:
>  >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>  >
>  >
>  >On Aug 30, 2004, at 1:01 PM, Jens Axel Søgaard wrote:
>  >
>  >>  For list-related administrative tasks:
>  >>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>  >>
>  >> Eli Barzilay wrote:
>  >>
>  >>> 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.
>  >>>
>  >> Or not-break-exn? .
>  >
>  >not-break-exn? is probably better, since you typically don't want to 
>  >catch break exceptions (or, you want to only catch break exceptions). 
>  >In upcoming releases, you'd probably want to use exn:fail?
>  >
>  >Robby
>  >
>  >


Posted on the users mailing list.