[plt-scheme] user defined exceptions

From: David J. Neu (djneu at att.net)
Date: Sat Jan 17 07:29:25 EST 2004


I was wondering if I could get some guidance on how to create a set of
"user defined" exceptions, i.e. exceptions that are specific to my
application. The two options I was looking at were:

1. Create a subtype of the structure exn.  For example, I created
   a subtype called exn:db using

         (define-struct (exn:db  exn) ())

   and then when the condition that triggered the exception was
   encountered I used the following to raise it

         (let ((e (make-exn:db "my error message" #f)))
          (raise e)))

    However, I'm not sure what I should be putting in the second
    argument to make-exn:db, where I have #f?

2. Create my own single field structure, with the single field
   containing the error message, and create subtypes of it for
   specific exceptions.

Thanks very much for any suggestions!


Posted on the users mailing list.