Skip to content

Commit 883e0d5

Browse files
yungstersfacebook-github-bot
authored andcommitted
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
1 parent 59abb5f commit 883e0d5

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

Libraries/Core/ExceptionsManager.js

+22-20
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,30 @@ function reportException(
112112
});
113113
}
114114

115-
NativeExceptionsManager.reportException(data);
115+
if (e.type !== 'warn') {
116+
NativeExceptionsManager.reportException(data);
116117

117-
if (__DEV__ && !global.RN$Express) {
118-
if (e.preventSymbolication === true) {
119-
return;
118+
if (__DEV__ && !global.RN$Express) {
119+
if (e.preventSymbolication === true) {
120+
return;
121+
}
122+
const symbolicateStackTrace = require('./Devtools/symbolicateStackTrace');
123+
symbolicateStackTrace(stack)
124+
.then(({stack: prettyStack}) => {
125+
if (prettyStack) {
126+
NativeExceptionsManager.updateExceptionMessage(
127+
data.message,
128+
prettyStack,
129+
currentExceptionID,
130+
);
131+
} else {
132+
throw new Error('The stack is null');
133+
}
134+
})
135+
.catch(error => {
136+
console.log('Unable to symbolicate stack trace: ' + error.message);
137+
});
120138
}
121-
const symbolicateStackTrace = require('./Devtools/symbolicateStackTrace');
122-
symbolicateStackTrace(stack)
123-
.then(({stack: prettyStack}) => {
124-
if (prettyStack) {
125-
NativeExceptionsManager.updateExceptionMessage(
126-
data.message,
127-
prettyStack,
128-
currentExceptionID,
129-
);
130-
} else {
131-
throw new Error('The stack is null');
132-
}
133-
})
134-
.catch(error => {
135-
console.log('Unable to symbolicate stack trace: ' + error.message);
136-
});
137139
}
138140
} else if (reportToConsole) {
139141
// we feed back into console.error, to make sure any methods that are

Libraries/Core/ExtendedError.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export type ExtendedError = Error & {
1414
componentStack?: string,
1515
forceRedbox?: boolean,
1616
isComponentError?: boolean,
17+
type?: string,
1718
...
1819
};

0 commit comments

Comments
 (0)