help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] exceptions


From: Stephen Compall
Subject: Re: [Help-smalltalk] exceptions
Date: Tue, 31 Oct 2006 12:44:56 -0600
User-agent: Thunderbird 1.5.0.7 (Macintosh/20060909)

Robin Redeker wrote:
> So basically the object 1 doesn't understand some exception handling
> message and throws an exception itself, which seems to trigger the
> handler again. - I would expect that a exception thrown while catching
> one (where the catching process fails) would throw that exception so
> that it doesn't trigger the same catching process. But maybe i'm just
> plain wrong with my expectations.

I spotted a workaround that doesn't mess with the current handler stack:

!Object methodsFor: 'exception handling'!
goodness: anException
    "Answer an integer indicating whether a handler with me as
    the 'on:' argument can handle anException, where a negative
    number means it can't."
    ^-1
! !

st> [self error: 'foo'] on: 1 do: [:ex | ex return]!
Object: nil error: foo
Error(Exception)>>#signal
Error(Exception)>>#signal:
UndefinedObject(Object)>>#error:
optimized [] in UndefinedObject>>#executeStatements
BlockClosure>>#on:do:
UndefinedObject>>#executeStatements
st>

-- 
Stephen Compall
http://scompall.nocandysw.com/blog
##smalltalk,#gnu-smalltalk on Freenode IRC




reply via email to

[Prev in Thread] Current Thread [Next in Thread]