semantics of Exception>>outer ?
Ned Konz
ned at bike-nomad.com
Fri Jun 27 15:24:51 UTC 2003
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
|