[squeak-dev] order of ensure: processing vs. error handling

Levente Uzonyi leves at caesar.elte.hu
Mon Sep 5 23:02:20 UTC 2016


On Mon, 5 Sep 2016, Chris Muller wrote:

> Thank you.  That makes perfect sense, when the Error is signaled, it must enter into the handler *deeper* in the stack (not unwound), and so of course its still IN the first part of the #ensure: method
> (valuing itself).  Got it.
>       @Chris: If I were you, I wouldn't bother with such magic. Instead, I'd use a linear approach:
>
>       | isTheFileOpen |
>       isTheFileOpen := false.
>       [ try the first method. isTheFileOpen := true ] ifError: [].
>       isTheFileOpen ifFalse: [
>               [ try the second method. isTheFileOpen := true ] ifError: [].
>               isTheFileOpen ifFalse: [
>                       [ try the third method. isTheFileOpen := true ] ifError: [].
>                       ... ] ].
> 
> 
> Yes, I'll have to go sequential.
> 
> PS -- I don't care to use ifError: because it doesn't give me access to the Exception object, only its description and receiver.  I think it should more closely mirror on: Error do: [ :err | ... ].

It's too late to change it. It's still useful when you don't care about 
the error nor the performance of the code.

Levente

> 
> 
>


More information about the Squeak-dev mailing list