diff --git a/Libraries/Core/ExceptionsManager.js b/Libraries/Core/ExceptionsManager.js index a9c68a7ed9eafd..6e64a40ad48a66 100644 --- a/Libraries/Core/ExceptionsManager.js +++ b/Libraries/Core/ExceptionsManager.js @@ -112,7 +112,7 @@ function reportException( }); } - if (e.type !== 'warn') { + if (isFatal || e.type !== 'warn') { NativeExceptionsManager.reportException(data); if (__DEV__ && !global.RN$Express) { diff --git a/Libraries/Core/__tests__/ExceptionsManager-test.js b/Libraries/Core/__tests__/ExceptionsManager-test.js index 228bd9c2b3b8ec..ffd3be593eebe2 100644 --- a/Libraries/Core/__tests__/ExceptionsManager-test.js +++ b/Libraries/Core/__tests__/ExceptionsManager-test.js @@ -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'; @@ -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', () => {