Skip to content

Commit

Permalink
RN: Suppress Warning-Like Errors
Browse files Browse the repository at this point in the history
Summary:
Changes `ExceptionsManager` in React Native so that errors with a `type` property equal to `'warn'` are not reported.

This change is banking on the fact that `type` is a non-standard and uncommon property on `Error` instances. If this ends up being problematic, we can instead change this to use a `unstable_type` or `unstable_level` property instead.

Changelog:
[General][Changed] - ExceptionsManager will no longer report exceptions with `type === 'warn'`.

Reviewed By: motiz88

Differential Revision: D28421692

fbshipit-source-id: 3ca19e29f32c8c5cad6dac637dcb930944fb24ed
  • Loading branch information
yungsters authored and facebook-github-bot committed May 21, 2021
1 parent 59abb5f commit 883e0d5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
42 changes: 22 additions & 20 deletions Libraries/Core/ExceptionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,30 @@ function reportException(
});
}

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

if (__DEV__ && !global.RN$Express) {
if (e.preventSymbolication === true) {
return;
if (__DEV__ && !global.RN$Express) {
if (e.preventSymbolication === true) {
return;
}
const symbolicateStackTrace = require('./Devtools/symbolicateStackTrace');
symbolicateStackTrace(stack)
.then(({stack: prettyStack}) => {
if (prettyStack) {
NativeExceptionsManager.updateExceptionMessage(
data.message,
prettyStack,
currentExceptionID,
);
} else {
throw new Error('The stack is null');
}
})
.catch(error => {
console.log('Unable to symbolicate stack trace: ' + error.message);
});
}
const symbolicateStackTrace = require('./Devtools/symbolicateStackTrace');
symbolicateStackTrace(stack)
.then(({stack: prettyStack}) => {
if (prettyStack) {
NativeExceptionsManager.updateExceptionMessage(
data.message,
prettyStack,
currentExceptionID,
);
} else {
throw new Error('The stack is null');
}
})
.catch(error => {
console.log('Unable to symbolicate stack trace: ' + error.message);
});
}
} else if (reportToConsole) {
// we feed back into console.error, to make sure any methods that are
Expand Down
1 change: 1 addition & 0 deletions Libraries/Core/ExtendedError.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export type ExtendedError = Error & {
componentStack?: string,
forceRedbox?: boolean,
isComponentError?: boolean,
type?: string,
...
};

0 comments on commit 883e0d5

Please sign in to comment.