[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSTimer doesn't catch exception when selector is performed
From: |
andre levy |
Subject: |
NSTimer doesn't catch exception when selector is performed |
Date: |
Tue, 07 Sep 2004 16:49:04 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 |
when NSTimer performs a selector and the selector fires an exception
nobody catches the exception. this causes the appli to crash.
since we cannot afford to have this behaviour (our customers may write
code that fires exception) we have to catch the exception and log a
message. actually Mac OSX does just that.
therefore we do:
- (void) fire
{
if (_selector == 0)
{
NS_DURING
[(NSInvocation*)_target invoke];
NS_HANDLER
NSLog(@"*** NSTimer ignoring exception '%@' (reason '%@') that raised
during posting of timer with target %p and selector '%@'",
[localException name], [localException reason], _target,
NSStringFromSelector([_target selector]));
NS_ENDHANDLER
}
else
{
NS_DURING
[_target performSelector: _selector withObject: self];
NS_HANDLER
NSLog(@"*** NSTimer ignoring exception '%@' (reason '%@') that raised
during posting of timer with target %p and selector '%@'",
[localException name], [localException reason], _target,
NSStringFromSelector(_selector));
NS_ENDHANDLER
}
...
}
a bit verbose. but I hope you get the idea...
should it be the default behaviour?
thanks a lot!
--andre
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- NSTimer doesn't catch exception when selector is performed,
andre levy <=