JSStackTrace -> Ensure lineNumber exists before consuming (#24399)

Summary:
Fixes https://github.com/facebook/react-native/issues/24382

[ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsing JS stack frames without line numbers.
Pull Request resolved: https://github.com/facebook/react-native/pull/24399

Differential Revision: D14890746

Pulled By: cpojer

fbshipit-source-id: cea3653076484ad624084c370439f8a39c303083
This commit is contained in:
Mike Diarmid 2019-04-11 03:11:24 -07:00 committed by Mike Grabowski
parent 72b4cc091d
commit d7bd6cce38
1 changed files with 13 additions and 2 deletions

View File

@ -24,8 +24,18 @@ public class JSStackTrace {
stringBuilder
.append(frame.getString("methodName"))
.append("@")
.append(parseFileId(frame))
.append(parseFileId(frame));
if (frame.hasKey("lineNumber") &&
!frame.isNull("lineNumber") &&
frame.getType("lineNumber") == ReadableType.Number) {
stringBuilder
.append(frame.getInt("lineNumber"));
} else {
stringBuilder
.append(-1);
}
if (frame.hasKey("column") &&
!frame.isNull("column") &&
frame.getType("column") == ReadableType.Number) {
@ -33,6 +43,7 @@ public class JSStackTrace {
.append(":")
.append(frame.getInt("column"));
}
stringBuilder.append("\n");
}
return stringBuilder.toString();