Fixed redbox error loop when camera access is disabled

This commit is contained in:
Nick Lockwood 2015-05-06 17:23:57 -07:00
parent 8d83b7ff63
commit 47164baaec
2 changed files with 30 additions and 39 deletions

View File

@ -1495,17 +1495,13 @@ RCT_BRIDGE_WARN(_invokeAndProcessModule:(NSString *)module method:(NSString *)me
return;
}
if (!RCT_DEBUG) {
[method invokeWithBridge:strongSelf module:module arguments:params context:context];
} else {
@try {
[method invokeWithBridge:strongSelf module:module arguments:params context:context];
}
@catch (NSException *exception) {
RCTLogError(@"Exception thrown while invoking %@ on target %@ with params %@: %@", method.JSMethodName, module, params, exception);
if ([exception.name rangeOfString:@"Unhandled JS Exception"].location != NSNotFound) {
@throw;
}
if (!RCT_DEBUG && [exception.name rangeOfString:@"Unhandled JS Exception"].location != NSNotFound) {
@throw exception;
}
}

View File

@ -44,11 +44,9 @@ RCT_EXPORT_METHOD(reportUnhandledException:(NSString *)message
return;
}
#if RCT_DEBUG // Red box is only available in debug mode
[[RCTRedBox sharedInstance] showErrorMessage:message withStack:stack];
#else
if (!RCT_DEBUG) {
static NSUInteger reloadRetries = 0;
const NSUInteger maxMessageLength = 75;
@ -73,21 +71,18 @@ RCT_EXPORT_METHOD(reportUnhandledException:(NSString *)message
NSString *name = [@"Unhandled JS Exception: " stringByAppendingString:message];
[NSException raise:name format:@"Message: %@, stack: %@", message, prettyStack];
}
#endif
}
}
RCT_EXPORT_METHOD(updateExceptionMessage:(NSString *)message
stack:(NSArray *)stack)
{
#if RCT_DEBUG // Red box is only available in debug mode
if (_delegate) {
[_delegate unhandledJSExceptionWithMessage:message stack:stack];
return;
}
[[RCTRedBox sharedInstance] updateErrorMessage:message withStack:stack];
#endif
}
@end