Add nullcheck in ExceptionsManager.js to Never Update JS Exception with a Null Stack

Summary:
JS codes sometimes report exceptions with `null` details about stack traces, resulting in native `NullPointerException` crashes when parsing the stack traces.
Added null checking for the stack traces in `ExceptionsManager.js`, ensuring that we never call `updateExceptionMessage` with a null stack

Reviewed By: foghina

Differential Revision: D3455783

fbshipit-source-id: 027969afd8a5d6015e97fce0a26626730cfc83a4
This commit is contained in:
Siqi Liu 2016-06-28 09:33:52 -07:00 committed by Facebook Github Bot
parent 30376aef13
commit 6fb110e776

View File

@ -31,8 +31,14 @@ function reportException(e: Error, isFatal: bool) {
}
if (__DEV__) {
symbolicateStackTrace(stack).then(
(prettyStack) =>
RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack, currentExceptionID),
(prettyStack) => {
if (prettyStack) {
RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack, currentExceptionID);
} else {
throw new Error('The stack is null');
}
}
).catch(
(error) =>
console.warn('Unable to symbolicate stack trace: ' + error.message)
);