Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zone.js): add a zone config to allow user disable wrapping uncaught promise rejection #35873

Closed

Commits on Mar 9, 2020

  1. feat(zone.js): add a zone config to allow user disable wrapping uncau…

    …ght promise rejection
    
    Close angular#27840.
    
    By default, `zone.js` wrap uncaught promise error and wrap it to a new Error object with some
    additional information includes the value of the error and the stack trace.
    
    Consider the following example:
    
    ```
    Zone.current
      .fork({
        name: 'promise-error',
        onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any): boolean => {
          console.log('caught an error', error);
          delegate.handleError(target, error);
          return false;
        }
    }).run(() => {
      const originalError = new Error('testError');
      Promise.reject(originalError);
    });
    ```
    
    The `promise-error` zone catches a wrapped `Error` object whose `rejection` property equals
    to the original error, and the message will be `Uncaught (in promise): testError....`,
    You can disable this wrapping behavior by defining a global configuraiton
    `__zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION = true;` before importing `zone.js`.
    JiaLiPassion committed Mar 9, 2020
    Configuration menu
    Copy the full SHA
    96f648c View commit details
    Browse the repository at this point in the history