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

promise API throws errors instead of rejecting promise #99

Closed
dylang opened this issue Sep 11, 2015 · 2 comments
Closed

promise API throws errors instead of rejecting promise #99

dylang opened this issue Sep 11, 2015 · 2 comments

Comments

@dylang
Copy link

dylang commented Sep 11, 2015

I believe it's an anti-pattern to synchronously throw errors in promises.

Example:

var mightBeFalse = false;
got(mightBeFalse)
    .then(doStuff)
    .catch(handleRejectedPromise); 

got synchronously throws

Parameter `url` must be a string or object, not boolean

Instead of rejecting the promise which would be handled by handleRejectedPromises.

@floatdrop
Copy link
Contributor

@dylang yeah, errors in Promise API should be returned as rejected promises. Good catch 👍

@dylang
Copy link
Author

dylang commented Sep 12, 2015

Thanks @floatdrop!

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

No branches or pull requests

2 participants