Skip to content

Commit f87b673

Browse files
davidaurelioFacebook Github Bot 4
authored andcommitted
Add possibility to console.error/redbox on promise rejections
Summary: Adds a possibility to `console.error` / redbox if any promise is rejected. Differential Revision: D3048130 fb-gh-sync-id: b1a44b421ec3b1f7913226c86b2a48f00f27b105 shipit-source-id: b1a44b421ec3b1f7913226c86b2a48f00f27b105
1 parent 205b5d4 commit f87b673

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright (c) 2016-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @providesModule promiseRejectionIsError
10+
* @flow
11+
*/
12+
13+
require('Promise'); // make sure the default rejection handler is installed
14+
const rejectionTracking = require('promise/setimmediate/rejection-tracking');
15+
16+
module.exports = () => {
17+
rejectionTracking.enable({
18+
allRejections: true,
19+
onUnhandled: (id, error) => {
20+
console.error(error);
21+
},
22+
onHandled: () => {},
23+
});
24+
};

0 commit comments

Comments
 (0)