PHP 7.4.33
Preview: promiseRejectionTrackingOptions.js Size: 2.17 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-native/Libraries/promiseRejectionTrackingOptions.js
/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * @flow strict
 */

import typeof {enable} from 'promise/setimmediate/rejection-tracking';

import LogBox from './LogBox/LogBox';

let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = {
  allRejections: true,
  onUnhandled: (id, rejection = {}) => {
    let message: string;
    let stack: ?string;

    // $FlowFixMe[method-unbinding] added when improving typing for this parameters
    const stringValue = Object.prototype.toString.call(rejection);
    if (stringValue === '[object Error]') {
      // $FlowFixMe[method-unbinding] added when improving typing for this parameters
      message = Error.prototype.toString.call(rejection);
      const error: Error = (rejection: $FlowFixMe);
      stack = error.stack;
    } else {
      try {
        message = require('pretty-format').format(rejection);
      } catch {
        message =
          typeof rejection === 'string'
            ? rejection
            : JSON.stringify((rejection: $FlowFixMe));
      }
      // It could although this object is not a standard error, it still has stack information to unwind
      // $FlowFixMe ignore types just check if stack is there
      if (rejection?.stack && typeof rejection.stack === 'string') {
        stack = rejection.stack;
      }
    }

    const warning = `Possible unhandled promise rejection (id: ${id}):\n${
      message ?? ''
    }`;
    if (__DEV__) {
      LogBox.addLog({
        level: 'warn',
        message: {
          content: warning,
          substitutions: [],
        },
        componentStack: [],
        componentStackType: null,
        stack,
        category: 'possible_unhandled_promise_rejection',
      });
    } else {
      console.warn(warning);
    }
  },
  onHandled: id => {
    const warning =
      `Promise rejection handled (id: ${id})\n` +
      'This means you can ignore any previous messages of the form ' +
      `"Possible unhandled promise rejection (id: ${id}):"`;
    console.warn(warning);
  },
};

export default rejectionTrackingOptions;

Directory Contents

Dirs: 51 × Files: 3
Name Size Perms Modified Actions
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Alert DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Animated DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
AppState DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Blob DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Core DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Debugging DIR
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Events DIR
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Image DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Inspector DIR
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Linking DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Lists DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
LogBox DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Modal DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
Network DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
Renderer DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Required DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Settings DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Share DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Text DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Types DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Utilities DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
vendor DIR
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
Vibration DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
WebSocket DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
Wrapper DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
YellowBox DIR
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
512 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.17 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.61 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).