Anonymous user
Exceptions/Catch an exception thrown in a nested call: Difference between revisions
Exceptions/Catch an exception thrown in a nested call (view source)
Revision as of 03:58, 20 January 2013
, 11 years ago→{{header|Smalltalk}}
(smalltalk) |
|||
Line 1,676:
foo value
</lang>
"traditional" implementation, using class based exceptions, and method invocations:
Exception
subclass: #U0
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'example'.
Exception
subclass: #U1
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'example'.
Object
subclass: #CatchMeIfYouCan
instanceVariableNames:'bazAlreadyCalled'
classVariableNames:''
poolDictionaries:''
category:'example'.
" CatchMeIfYouCan methods "
foo
2 timesRepeat:[
[ self bar ]
on: U0
do:[ 'U0 cought' printCR ]
]
bar
self baz
baz
bazAlreadyCalled isNil ifTrue:[
bazAlreadyCalled := true.
U0 raise
] ifFalse:[
U1 raise
]
CatchMeIfYouCan new foo
=={{header|Tcl}}==
|