Skip to content

Commit

Permalink
fix(ios): handle uncaught exceptions in timer callbacks
Browse files Browse the repository at this point in the history
Fixes TIMOB-27528
  • Loading branch information
sgtcoolguy committed Jan 23, 2020
1 parent 1db98a8 commit bae7732
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2018 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2018-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#import "KrollTimerManager.h"
#import "TiBindingTiValue.h"
#import "TiExceptionHandler.h"
#import "TiUtils.h"

Expand Down Expand Up @@ -45,6 +46,13 @@ - (void)dealloc
- (void)timerFired:(NSTimer *_Nonnull)timer
{
[self.callback callWithArguments:self.arguments];
// handle an uncaught exception
JSContext *context = self.callback.context;
JSValue *exception = context.exception;
if (exception != nil) {
NSDictionary *exceptionDict = TiBindingTiValueToNSObject(context.JSGlobalContextRef, exception.JSValueRef);
[[TiExceptionHandler defaultExceptionHandler] reportScriptError:[TiUtils scriptErrorValue:exceptionDict]];
}
}

@end
Expand Down

0 comments on commit bae7732

Please sign in to comment.