From 199542334ab4c211fc144144954a39ad76ecaefb Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Tue, 7 Sep 2004 16:54:16 +0000 Subject: [PATCH] Log exceptions when timer fires git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20025 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 1 + Source/NSTimer.m | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5081ffcfd..a0a3c6609 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ * Source/GSSet.m: ([allObjects]) Fix stack overflow for large sets. * Source/NSTask.m: Fix error testing for task which has been lost. * Source/NSArray.m: Fix possible stack overflows + * Source/NSTimer.m: Log uncaught exceptions when timer fires. Thanks to Andre Levey for reporting these. 2004-09-07 Richard Frith-Macdonald diff --git a/Source/NSTimer.m b/Source/NSTimer.m index b856f5cf4..7f8e97b8a 100644 --- a/Source/NSTimer.m +++ b/Source/NSTimer.m @@ -196,11 +196,33 @@ static Class NSDate_class; { if (_selector == 0) { - [(NSInvocation*)_target invoke]; + NS_DURING + { + [(NSInvocation*)_target invoke]; + } + NS_HANDLER + { + NSLog(@"*** NSTimer ignoring exception '%@' (reason '%@') " + @"raised during posting of timer with target %p and selector '%@'", + [localException name], [localException reason], _target, + NSStringFromSelector([_target selector])); + } + NS_ENDHANDLER } else { - [_target performSelector: _selector withObject: self]; + NS_DURING + { + [_target performSelector: _selector withObject: self]; + } + NS_HANDLER + { + NSLog(@"*** NSTimer ignoring exception '%@' (reason '%@') " + @"raised during posting of timer with target %p and selector '%@'", + [localException name], [localException reason], _target, + NSStringFromSelector(_selector)); + } + NS_ENDHANDLER } if (_repeats == NO)