Make onUnhandled safe for undefined errors
Summary: This pull request fixes cases where the `error` argument of the `onUnhandled` method in `Libraries/Promise.js` is undefined. Previously this would result in a redbox with the helpful message: `Cannot read property message of undefined`. With this pull request, unhandled promise rejections result in the desired yellowbox saying that a promise rejection went unhandled. I still do not know what would cause the error argument to be undefined, but this change makes the module behave as expected in an app I am building. cc bestander Relevant issue: #8452 Closes https://github.com/facebook/react-native/pull/9119 Differential Revision: D3655589 Pulled By: bestander fbshipit-source-id: a975a0ab58701240ba06574c04521cd542700ff7
This commit is contained in:
parent
0418353249
commit
591217ea7d
|
@ -16,8 +16,8 @@ const Promise = require('fbjs/lib/Promise.native');
|
|||
if (__DEV__) {
|
||||
require('promise/setimmediate/rejection-tracking').enable({
|
||||
allRejections: true,
|
||||
onUnhandled: (id, error) => {
|
||||
const {message, stack} = error;
|
||||
onUnhandled: (id, error = {}) => {
|
||||
const {message = null, stack = null} = error;
|
||||
const warning =
|
||||
`Possible Unhandled Promise Rejection (id: ${id}):\n` +
|
||||
(message == null ? '' : `${message}\n`) +
|
||||
|
|
Loading…
Reference in New Issue