-
Notifications
You must be signed in to change notification settings - Fork 15
Consistency question, re: handling of exceptions thrown during input validation #28
Comments
@syg @lars-t-hansen I'm in the process of writing tests for this feature and I'm finding that this issue keeps coming up. Can I get some thoughts here? Also, I want to hear from @ljharb as well. |
This is a good catch; |
This comment has been minimized.
This comment has been minimized.
My current thinking is that validation errors should reject the promise. |
Though to be clear this is a needs-consensus change. I'll make a PR to the agenda for a deprioritized item. |
@ljharb I've chatted with some more folks since #28 (comment) and @jridgewell pointed me to https://2ality.com/2016/03/promise-rejections-vs-exceptions.html, which seems well reasoned. That argues that invalidation errors should fail fast and remain synchronous exceptions. Are there API examples where invalidation errors are turned into Promise rejections? |
Yes, |
As another counterpoint to the status quo, I was pointed to https://www.w3.org/2001/tag/doc/promises-guide#always-return-promises. |
And |
Looks like we have solution |
Currently, any errors that occur as a result of failed input validation are thrown synchronously. This means that safe usage of
Atomics.waitAsync()
will look like this:The
sync
flag inDoWait()
could be used to instead handle these errors viaIfAbruptRejectPromise(abrupt completion value, promiseCapability)
.WDYT?
The text was updated successfully, but these errors were encountered: