Fix check for rethrowing RCTFatal exceptions

Summary: I changed the format slightly of the exception being generated in RCTFatal, so we we're catching and rethrowing it, which left some useful information of the error stack.

public

Reviewed By: majak

Differential Revision: D2631341

fb-gh-sync-id: feb4939f58014171a55cd74f20f57bcd6dfddc1e
This commit is contained in:
Pieter De Baets 2015-11-10 04:29:39 -08:00 committed by facebook-github-bot-7
parent caf111eb23
commit a377f81b4e
3 changed files with 8 additions and 2 deletions

View File

@ -50,6 +50,11 @@ RCT_EXTERN NSString *const RCTErrorDomain;
*/
RCT_EXTERN NSString *const RCTJSStackTraceKey;
/**
* Name of fatal exceptions generated by RCTFatal
*/
RCT_EXTERN NSString *const RCTFatalExceptionName;
/**
* A block signature to be used for custom assertion handling.
*/

View File

@ -12,6 +12,7 @@
NSString *const RCTErrorDomain = @"RCTErrorDomain";
NSString *const RCTJSStackTraceKey = @"RCTJSStackTraceKey";
NSString *const RCTFatalExceptionName = @"RCTFatalException";
static NSString *const RCTAssertFunctionStack = @"RCTAssertFunctionStack";
@ -128,7 +129,7 @@ void RCTFatal(NSError *error)
@try {
#endif
NSString *message = RCTFormatError([error localizedDescription], error.userInfo[RCTJSStackTraceKey], 75);
[NSException raise:@"RCTFatalException" format:@"%@", message];
[NSException raise:RCTFatalExceptionName format:@"%@", message];
#if DEBUG
} @catch (NSException *e) {}
#endif

View File

@ -805,7 +805,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
}
@catch (NSException *exception) {
// Pass on JS exceptions
if ([exception.name rangeOfString:@"Unhandled JS Exception"].location == 0) {
if ([exception.name isEqualToString:RCTFatalExceptionName]) {
@throw exception;
}