Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Is re-throwing in promises going to be supported by $q at some point? #13990

@adamreisnz

Description

@adamreisnz

The docs for $q state:

Note: unlike ES6 behavior, an exception thrown in the constructor function will NOT implicitly reject the promise.

and

This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject

So my question is, is this planned to be supported at any time in Angular 1? In a successful .then chain we can keep returning the same item/data, or modify it and return that, so why not re-throw an error in .catch that occurred without needing to include $q as a dependency?

E.g.

doSomething
  .catch(error => {
    doSomethingElse();
    throw error;
  });

instead of:

doSomething
  .catch(error => {
    doSomethingElse();
    return $q.reject(error);
  });

If not, is there a specific reason for this not being supported in $q?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions