Skip to content

Commit

Permalink
ExceptionsManager: Report Fatal "Warnings"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Jun 2, 2021
1 parent 286fac5 commit e4a4c4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Libraries/Core/ExceptionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function reportException(
});
}

if (e.type !== 'warn') {
if (isFatal || e.type !== 'warn') {
NativeExceptionsManager.reportException(data);

if (__DEV__ && !global.RN$Express) {
Expand Down
18 changes: 18 additions & 0 deletions Libraries/Core/__tests__/ExceptionsManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ describe('ExceptionsManager', () => {
expect(nativeReportException).toHaveBeenCalled();
});

test('does not log "warn"-type errors', () => {
const error = new Error('This is a warning.');
error.type = 'warn';

console.error(error);

expect(nativeReportException).not.toHaveBeenCalled();
});

test('reportErrorsAsExceptions = false', () => {
console.reportErrorsAsExceptions = false;
const message = 'Some error happened';
Expand Down Expand Up @@ -470,6 +479,15 @@ describe('ExceptionsManager', () => {
"const error = new Error('Some error happened');",
);
});

test('logs fatal "warn"-type errors', () => {
const error = new Error('This is a fatal... warning?');
error.type = 'warn';

ExceptionsManager.handleException(error, true);

expect(nativeReportException).toHaveBeenCalled();
});
});

describe('unstable_setExceptionDecorator', () => {
Expand Down

0 comments on commit e4a4c4d

Please sign in to comment.