RN: Suppress Warning-Like Errors

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
This commit is contained in:
Tim Yung 2021-05-20 19:06:53 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 59abb5f378
Коммит 883e0d5752
2 изменённых файлов: 23 добавлений и 20 удалений

Просмотреть файл

@ -112,28 +112,30 @@ function reportException(
}); });
} }
NativeExceptionsManager.reportException(data); if (e.type !== 'warn') {
NativeExceptionsManager.reportException(data);
if (__DEV__ && !global.RN$Express) { if (__DEV__ && !global.RN$Express) {
if (e.preventSymbolication === true) { if (e.preventSymbolication === true) {
return; 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) { } else if (reportToConsole) {
// we feed back into console.error, to make sure any methods that are // we feed back into console.error, to make sure any methods that are

Просмотреть файл

@ -14,5 +14,6 @@ export type ExtendedError = Error & {
componentStack?: string, componentStack?: string,
forceRedbox?: boolean, forceRedbox?: boolean,
isComponentError?: boolean, isComponentError?: boolean,
type?: string,
... ...
}; };