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
Labels
Milestone

Comments

@tracker1
Copy link

@tracker1 tracker1 commented Feb 19, 2015

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

@dmethvin dmethvin commented Feb 19, 2015

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.

@markelog markelog added the Deferred label Feb 19, 2015
@tracker1
Copy link
Author

@tracker1 tracker1 commented Feb 19, 2015

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 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

@gibson042 gibson042 commented Apr 22, 2015

I updated the title for accuracy. Suggested implementation:

"catch": function( fn ) {
    return promise.then( null, fn );
}
@markelog
Copy link
Member

@markelog markelog commented Apr 23, 2015

Sounds like a blocker to me

@timmywil timmywil added the Blocker label Apr 23, 2015
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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.