semantics of Exception>>outer ?
John W. Sarkela
sarkela at sbcglobal.net
Mon Jul 7 09:08:06 UTC 2003
Hi,
I've been off the list for a while and am currently forging through a
huge backlog. I have looked forward to see replies to this message.
I'll not address the ANSI standard as John Brant has already pointed
out the relevant sections of the spec with a lucid example of the
distinction between outer and pass.
ANSI Smalltalk exceptions are *always* handled at some point. All
exceptions get handled, not all exceptions are recoverable. If the
exception is unrecoverable, the call chain is curtailed. This is the
case in which execution is cut short and frames are dropped. Note well
that this is precisely the case in which the exception handler was
unable to recover from the exception.
Thus, #ifError: should almost certainly be replaced with #ifCurtailed:.
I can imagine no context in which it makes sense to use the selector
#ifUnhandledError:. I presume that by unhandled error, you intend to
distinguish errors for which no handler is able to retry or resume.
:-}> John Sarkela
On Friday, June 27, 2003, at 08:24 AM, Ned Konz wrote:
> I am trying to get rid of #ifError: and make it so that outer scopes
> can provide exception handlers for its existing callers.
>
> So I'm writing a method BlockContext>>ifUnhandledError: that's
> somewhat similar, but that would pass the error through to any
> enclosing handlers in preference to the failBlock.
>
> So I tried something like this (simplified):
>
> ifUnhandledError: errorHandlerBlock
> ^self on: Error do: [ :ex |
> ex isNested
> ifTrue: [ ex outer ]
> ifFalse: [ errorHandlerBlock value ]]
>
> But it didn't work as I wanted it to: the outer handler didn't get
> called. Looking further into this, I saw that:
>
> [ self error: 'xx' ] on: Error
> do: [ :ex | ex isNested ifFalse: [ ex return: 'not nested' ]]
>
> => 'not nested', OK.
>
> [[ self error: 'xx' ] on: Error
> do: [ :ex | ex isNested
> ifTrue: [ ex outer ]
> ifFalse: [ ex return: 'not nested' ]]]
> on: Error do: [ :ex | ex return: 'outer' ]
>
> => default handler gets called despite the existence of the outer
> handler.
>
> However, if I do this, the outer handler gets called as I expected:
>
> [[ self error: 'xx' ] on: Error
> do: [ :ex | ex isNested
> ifTrue: [ ex resignalAs: ex ]
> ifFalse: [ ex return: 'not nested' ]]]
> on: Error do: [ :ex | ex return: 'outer' ]
>
> So my question is: is #outer working as expected?
>
> Thanks,
> --
> Ned Konz
> http://bike-nomad.com
> GPG key ID: BEEA7EFE
>
More information about the Squeak-dev
mailing list
|