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

Comments

Projects
None yet
6 participants
@tracker1

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

This comment has been minimized.

Show comment
Hide comment
@dmethvin

dmethvin Feb 19, 2015

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@tracker1

tracker1 Feb 19, 2015

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

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

@dcherman

This comment has been minimized.

Show comment
Hide comment
@dcherman

dcherman Mar 2, 2015

Contributor

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.

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 from Alias .catch alias to Deferred's .fail handler. to 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

This comment has been minimized.

Show comment
Hide comment
@gibson042

gibson042 Apr 22, 2015

Member

I updated the title for accuracy. Suggested implementation:

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

gibson042 commented Apr 22, 2015

I updated the title for accuracy. Suggested implementation:

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

This comment has been minimized.

Show comment
Hide comment
@markelog

markelog Apr 23, 2015

Member

Sounds like a blocker to me

Member

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

@timmywil timmywil closed this in #2451 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.