promiseRejectionIsError.js 567 B

123456789101112131415161718192021222324
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow
  9. */
  10. 'use strict';
  11. require('./Promise'); // make sure the default rejection handler is installed
  12. const rejectionTracking = require('promise/setimmediate/rejection-tracking');
  13. module.exports = () => {
  14. rejectionTracking.enable({
  15. allRejections: true,
  16. onUnhandled: (id, error) => {
  17. console.error(error);
  18. },
  19. onHandled: () => {},
  20. });
  21. };