[plt-scheme] user defined exceptions

From: John Clements (clements at brinckerhoff.org)
Date: Tue Jan 20 11:20:23 EST 2004

On Jan 20, 2004, at 10:40 AM, Noel Welsh wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> --- "David J. Neu" <djneu at att.net> wrote:
>> I was wondering if I could get some guidance on how
>> to create a set of "user defined" exceptions...
>
> I haven't seen any answers to this, so...
>
> Do this:
>
>> 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
>
> Do this
>
>   (let ((e (make-exn:db "mesg"
> (current-continuation-marks))))
>     (raise e))
>
> HTH,
> Noel

To elaborate on Noel's response; calling (current-continuation-marks) 
gathers information about the execution that may later be helpful in 
understanding why the error occurred.  For instance, the "bug window" 
you get by clicking on the bug icon in some language levels draws its 
information from the continuation marks in the exception.

john



Posted on the users mailing list.