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

Add catch to promise objects #2102

Closed
tracker1 opened this issue Feb 19, 2015 · 5 comments
Closed

Add catch to promise objects #2102

tracker1 opened this issue Feb 19, 2015 · 5 comments
Assignees
Milestone

Comments

@tracker1
Copy link

This relates to #1722 but a far simpler request... given that the .then method matches the Promise spec (with the extra progress parameter), it would be nice that there be a compatible .catch method... (per @dmethvin) this could call and return .then(null,fn) as a passthrough.

@dmethvin
Copy link
Member

I can see us creating .catch(fn) as an alias for .then(null, fn). That is different than .done(fn) though because the latter adds a new handler to the existing Deferred.

@tracker1
Copy link
Author

of course, this would need to be done with ['catch'] so as not to trigger reserved word treatment in older browsers.

@dcherman
Copy link
Contributor

dcherman commented Mar 2, 2015

Giant +1 on this. Since these Promises aren't based on a prototype, it's much easier for this to be supported internally rather than having to do something like wrap the constructor and decorate the returned promise.

@gibson042 gibson042 changed the title Alias .catch alias to Deferred's .fail handler. Add catch to promise objects Apr 22, 2015
@gibson042 gibson042 added this to the 3.0.0 milestone Apr 22, 2015
@gibson042 gibson042 self-assigned this Apr 22, 2015
@gibson042
Copy link
Member

I updated the title for accuracy. Suggested implementation:

"catch": function( fn ) {
    return promise.then( null, fn );
}

@markelog
Copy link
Member

Sounds like a blocker to me

timmywil added a commit to timmywil/jquery that referenced this issue Jul 6, 2015
timmywil added a commit to timmywil/jquery that referenced this issue Jul 6, 2015
timmywil added a commit that referenced this issue Jul 6, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

6 participants