-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
Expected a Promise rejection for option errors #131
Comments
The existing behavior is correct. |
It does: it returns |
I see only downsides to returning validation errors as rejections (including but not limited to the fact that some environments swallow unhandled rejections by default). I can't think of any practical reason to do so. That's just my two cents. |
What are the downsides? I don't see any 😕 |
Benefits of throwing synchronously for input validation:
I'm not trying to say it's a huge deal. But to me, throwing synchronously seems obviously superior. The best counter argument I can come up with is that rejecting instead of throwing gives us some squishy notion of consistency that might be nice for users who do want to ignore these errors for some reason. But I can't imagine a scenario when someone would want to ignore input validation errors - it would effectively just make Ky a no-op, so there's no point. |
I'm rebasing the code (you can see the PR). The shorter one is Promise rejection.
That's true.
It depends on your point of view. Unhandled rejections? No problem, use global catch. @sindresorhus #127 (comment) said:
So, replying to:
I disagree. |
Sorry, @szmarczak is correct. I was reading the docs:
Which is incorrect. It should say:
|
@sholladay This should always be followed:
I was only closing as I was fooled by the docs. |
I haven't been able to find anything like that in ECMA-262, nor in Promises/A+. I might have missed it, but I'm skeptical they would make that choice as part of the spec. |
FWIW, that is not a spec. And this is the only part that I disagree with:
Anyway, I had to make throw-rejects as a more general solution to get async programs to crash properly and it will handle this case for anyone who remembers to use it. I can live with it... |
Hehe. I have https://github.com/sindresorhus/hard-rejection I think the Node.js team plans to eventually make uncaught rejections a hard error. |
Closing since this should be done, ever since the re-write to |
Expected behavior
A Promise rejection.
Current behavior
Errors are thrown directly.
Code to reproduce
The text was updated successfully, but these errors were encountered: