[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: question about error signaling
- To: firstname.lastname@example.org, email@example.com
- Subject: Re: question about error signaling
- From: firstname.lastname@example.org (Kalman Reti)
- Date: Wed, 3 Aug 1994 16:09:44 -0400
At 11:52 AM 8/3/94 -0400, email@example.com wrote:
>I've been playing around with the common lisp condition system and was
>wondering to what degree MCL 2.0.1 conformed to the pseudo-standard
>in CLtL2. I've successfully created my own conditions and am able to trap
>them, but when I tried to trap MCL's end-of-file condition I'm unable
>to catch it. (handler-case (exp)
> (end-of-file () blah))
>Does MCL output signals in that way? Or is there some way I can catch it?
>I've written an app that gets user input, and if they leave a parethesis off
>when I do a (read-from-string blah) MCL bombs with an error:
>> Error: Unexpected end of file encountered.
>> While executing: CCL::%READ-FORM
>> Type Command-. to abort.
>See the RestartsI menu item for further choices.
>which is totally expected. Can I catch this error in some way?
>MIT Media Lab
>Epistemology and Learning
For historical reasons (and perhaps also load-order reasons, since some types
of errors need to be able to be signalled before the condition system is loaded),
MCL signals SIMPLE-ERROR conditions for a bunch of different errors. This is
on the list for future cleanup.
As a workaround for now, you can sort out the various types of SIMPLE-ERRORs
from their REPORT-CONDITION output, viz:
(handler-bind ((simple-error #'(lambda (error)
(when (string-equal "unexpected end of file encountered."
(report-condition error nil))
...handle eof error here))))
This works because if a handler returns nil, i.e. the string didn't match, it means it is
declining to handle the condition, and the system tries the next handler.
For portable code, one thing you could do at the "...handle eof error here" is to signal
end-of-file. You'll have to have some way to get your hands on the stream you were
reading, since the SIMPLE-ERROR instance doesn't contain any pointer to it.