Exception handling question

Roel Wuyts wuyts at iam.unibe.ch
Sat Aug 2 22:58:02 UTC 2003


Hah, very interesting (I shortened the mail a bit so that the question 
is on top again). Summarizing:

> The most important point however is that Exception DOES NOT
> handle Halt (in spite of the fact that Halt is a subclass of 
> Exception.)

Because of this rule I am into trouble.
Can somebody motivate this decision (or whether it is an unintentional 
bug)?

On Saturday, Aug 2, 2003, at 23:35 Europe/Zurich, Boris Gaertner wrote:

>
> From: Roel Wuyts <wuyts at iam.unibe.ch>
>
>
>> Hello,
>> I am trying out some things under 3.6 (updated till #5373).
>>
>> The following statements did exactly what I thought they would:
>>      [self error: 'an error'] on: Error do: [:exc | Transcript show: 
>> exc
>> class name; cr].
>>      [self halt: 'a halt'] on: Halt do: [:exc | Transcript show: exc
>> class name; cr].
>> They print 'Error' and 'Halt' on the Transcript.
>>
>> But the following ones did not do what I expected:
>>      [self error: 'an error'] on: Exception do: [:exc | Transcript 
>> show:
>> exc class name; cr].
>>      [self halt: 'a halt'] on: Exception do: [:exc | Transcript show:
>> exc class name; cr].
>> It prints 'Error' and then (this is what I consider weird)
>> 'UnhandledError' ?!
>>
> In Squeak 3.4 #5170  the statement in question  opens a Debugger.
> The 'UnhandledError' comes from  Error>>defaultAction; a
> method that was recently changed. (ajh 9/4/2002)
>
> Error>>defaultAction is sent from  Exception>>signal.
> The most important point however is that Exception DOES NOT
> handle Halt (in spite of the fact that Halt is a subclass of 
> Exception.)
> The code for this exception to the general rule is in
> Exception class>>handles: exception   where we read:
>
> handles: exception
>  "Determine whether an exception handler will accept a signaled 
> exception."
>
>  (exception isKindOf: Halt) ifTrue: [^ false].
>  ^ exception isKindOf: self
>
> Exceptions that are a kind of a Halt are handled by Halt, but not
> by the superclasses (Error, Exception).
> I cannot tell you the history of that exception to the general rule
> that the more general exception should handle specialized
> exceptions.
>
>
>> I don't know enough to say whether this is a feature, a bug, or my
>> complete misunderstanding :-) Can somebody enlighten me?
>>
> I do not think that it is a bug, but I cannot explain why the
> feature is there. Does somebody know or remember?
>
> Greetings, Boris
>
>
>
Roel Wuyts                                                   Software 
Composition Group
roel.wuyts at iam.unibe.ch                       University of Bern, 
Switzerland
http://www.iam.unibe.ch/~wuyts/
Board Member of the European Smalltalk User Group: www.esug.org



More information about the Squeak-dev mailing list