Skip to content

Commit e4a4c4d

Browse files
yungstersfacebook-github-bot
authored andcommitted
ExceptionsManager: Report Fatal "Warnings"
Summary: As suggested by motiz88 on D28421692 (883e0d5), make sure to still report fatal "warnings". Changelog: [General][Fixed] Report fatal errors even if its `type` is "warn". Reviewed By: motiz88 Differential Revision: D28815228 fbshipit-source-id: 8d3b77958ef687a4ce64bdfccbf6ce2dc5557eaf
1 parent 286fac5 commit e4a4c4d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Libraries/Core/ExceptionsManager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function reportException(
112112
});
113113
}
114114

115-
if (e.type !== 'warn') {
115+
if (isFatal || e.type !== 'warn') {
116116
NativeExceptionsManager.reportException(data);
117117

118118
if (__DEV__ && !global.RN$Express) {

Libraries/Core/__tests__/ExceptionsManager-test.js

+18
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,15 @@ describe('ExceptionsManager', () => {
370370
expect(nativeReportException).toHaveBeenCalled();
371371
});
372372

373+
test('does not log "warn"-type errors', () => {
374+
const error = new Error('This is a warning.');
375+
error.type = 'warn';
376+
377+
console.error(error);
378+
379+
expect(nativeReportException).not.toHaveBeenCalled();
380+
});
381+
373382
test('reportErrorsAsExceptions = false', () => {
374383
console.reportErrorsAsExceptions = false;
375384
const message = 'Some error happened';
@@ -470,6 +479,15 @@ describe('ExceptionsManager', () => {
470479
"const error = new Error('Some error happened');",
471480
);
472481
});
482+
483+
test('logs fatal "warn"-type errors', () => {
484+
const error = new Error('This is a fatal... warning?');
485+
error.type = 'warn';
486+
487+
ExceptionsManager.handleException(error, true);
488+
489+
expect(nativeReportException).toHaveBeenCalled();
490+
});
473491
});
474492

475493
describe('unstable_setExceptionDecorator', () => {

0 commit comments

Comments
 (0)