mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-22 19:39:40 +08:00
Redo error handling on iOS
Reviewed By: danzimm Differential Revision: D5969343 fbshipit-source-id: 376984a6e959349260c54884c0b0b719f4c353d6
This commit is contained in:
committed by
Facebook Github Bot
parent
1e3a8e2ed4
commit
e87904cea5
@@ -18,7 +18,7 @@ static NSRegularExpression *RCTJSStackFrameRegex()
|
||||
static NSRegularExpression *_regex;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSError *regexError;
|
||||
_regex = [NSRegularExpression regularExpressionWithPattern:@"^([^@]+)@(.*):(\\d+):(\\d+)$" options:0 error:®exError];
|
||||
_regex = [NSRegularExpression regularExpressionWithPattern:@"^(?:([^@]+)@)?(.*):(\\d+):(\\d+)$" options:0 error:®exError];
|
||||
if (regexError) {
|
||||
RCTLogError(@"Failed to build regex: %@", [regexError localizedDescription]);
|
||||
}
|
||||
@@ -56,7 +56,9 @@ static NSRegularExpression *RCTJSStackFrameRegex()
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *methodName = [line substringWithRange:[match rangeAtIndex:1]];
|
||||
// methodName may not be present for e.g. anonymous functions
|
||||
const NSRange methodNameRange = [match rangeAtIndex:1];
|
||||
NSString *methodName = methodNameRange.location == NSNotFound ? nil : [line substringWithRange:methodNameRange];
|
||||
NSString *file = [line substringWithRange:[match rangeAtIndex:2]];
|
||||
NSString *lineNumber = [line substringWithRange:[match rangeAtIndex:3]];
|
||||
NSString *column = [line substringWithRange:[match rangeAtIndex:4]];
|
||||
@@ -69,7 +71,7 @@ static NSRegularExpression *RCTJSStackFrameRegex()
|
||||
|
||||
+ (instancetype)stackFrameWithDictionary:(NSDictionary *)dict
|
||||
{
|
||||
return [[self alloc] initWithMethodName:dict[@"methodName"]
|
||||
return [[self alloc] initWithMethodName:RCTNilIfNull(dict[@"methodName"])
|
||||
file:dict[@"file"]
|
||||
lineNumber:[RCTNilIfNull(dict[@"lineNumber"]) integerValue]
|
||||
column:[RCTNilIfNull(dict[@"column"]) integerValue]];
|
||||
|
||||
Reference in New Issue
Block a user