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:
Родитель
59abb5f378
Коммит
883e0d5752
|
@ -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
|
||||
|
|
|
@ -14,5 +14,6 @@ export type ExtendedError = Error & {
|
|||
componentStack?: string,
|
||||
forceRedbox?: boolean,
|
||||
isComponentError?: boolean,
|
||||
type?: string,
|
||||
...
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче