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

Shorthand for defining promise error handlers - $q.fail() #2048

Closed
pelme opened this issue Feb 21, 2013 · 11 comments
Closed

Shorthand for defining promise error handlers - $q.fail() #2048

pelme opened this issue Feb 21, 2013 · 11 comments

Comments

@pelme
Copy link
Contributor

pelme commented Feb 21, 2013

Kris Kowal's Q provides the fail() shorthand for defining error handlers.

Error handlers can then be defined as

promise.fail(function(error) { ... })

instead of

promise.then(null, function(error) { ... })

... which feels a bit clunky.

I realize that Angular's $q is meant to be minimal and without the bells and whistles of Q, so this might not be worth adding to Angulars $q implementation.

If you consider that fail() would be feasible to include in Angular's $q, let me know and I will be happy to create a pull request with a patch!

@cgarvis
Copy link

cgarvis commented Apr 11, 2013

+1. fail in Kris Kowal's Q makes cleaner code and better error handling.

@drawveloper
Copy link

+1 fail!

@leoneparise
Copy link

👍

@montlebalm
Copy link

Upvote for fail.

@jerbersoft
Copy link

this is not yet done. +1 for the fail method!

@jrawlings
Copy link

+1

1 similar comment
@devmondo
Copy link

👍

@jasdeepsingh
Copy link

👍 :

bolasblack added a commit to bolasblack/angular.js that referenced this issue Aug 9, 2013
Now we can instead this

    promise.then(null, errorHandler)

with this

    promise.catch(errorhandler)

Closes angular#2048
@matsko
Copy link
Contributor

matsko commented Aug 9, 2013

Thanks @IgorMinar for merging this.

@jasdeepsingh
Copy link

Sweet!

@codeablehq
Copy link

Is it possible to get another shorthand for when notification comes in, a shorthand for .then(null,null, onNotify);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants