Skip to content

Commit

Permalink
JSStackTrace -> Ensure lineNumber exists before consuming (#24399)
Browse files Browse the repository at this point in the history
Summary:
Fixes #24382

[ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsing JS stack frames without line numbers.
Pull Request resolved: #24399

Differential Revision: D14890746

Pulled By: cpojer

fbshipit-source-id: cea3653076484ad624084c370439f8a39c303083
  • Loading branch information
Salakar authored and facebook-github-bot committed Apr 11, 2019
1 parent 3b1760d commit c953e0b
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,26 @@ public static String format(String message, ReadableArray stack) {
stringBuilder
.append(frame.getString("methodName"))
.append("@")
.append(parseFileId(frame))
.append(frame.getInt("lineNumber"));
.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) {
stringBuilder
.append(":")
.append(frame.getInt("column"));
}

stringBuilder.append("\n");
}
return stringBuilder.toString();
Expand Down

0 comments on commit c953e0b

Please sign in to comment.