Skip to content

Commit

Permalink
Add Random Access Module file names to stack traces
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D3269450

fb-gh-sync-id: 41b2013d4422c2bcafa7628321d4626fd40aac5d
fbshipit-source-id: 41b2013d4422c2bcafa7628321d4626fd40aac5d
  • Loading branch information
davidaurelio authored and Facebook Github Bot 7 committed May 6, 2016
1 parent 097f591 commit 0c90ab4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion React/Base/RCTAssert.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,19 @@ RCTFatalHandler RCTGetFatalHandler(void)
NSMutableString *prettyStack = [NSMutableString string];
if (stackTrace) {
[prettyStack appendString:@", stack:\n"];

NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^(\\d+\\.js)$"
options:NSRegularExpressionCaseInsensitive
error:NULL];
for (NSDictionary<NSString *, id> *frame in stackTrace) {
[prettyStack appendFormat:@"%@@%@:%@\n", frame[@"methodName"], frame[@"lineNumber"], frame[@"column"]];
NSString *fileName = [frame[@"file"] lastPathComponent];
if (fileName && [regex numberOfMatchesInString:fileName options:0 range:NSMakeRange(0, [fileName length])]) {
fileName = [fileName stringByAppendingString:@":"];
} else {
fileName = @"";
}

[prettyStack appendFormat:@"%@@%@%@:%@\n", frame[@"methodName"], fileName, frame[@"lineNumber"], frame[@"column"]];
}
}

Expand Down

0 comments on commit 0c90ab4

Please sign in to comment.