-
Notifications
You must be signed in to change notification settings - Fork 22
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
Specify error mappings #57
Comments
"AbortError" is very specific and mainly for abort signals only. cc @domenic I'd also recommend considering that implementations might want some flexibility going forward so requiring rather unique exceptions might not be worthwhile if web developers aren't expected to branch on the exception names anyway. |
If there's specific action an application might want to take for a specific failure mode, then tightly specifying errors would be useful. Otherwise tightly specifying errors doesn't have much benefit I can see; though specifying them avoids unintentional lock-in by developers who look for a specific (non-specced) error, and then break if it changes -- or if they use a different browser. However, we should be in alignment with how other specs do (or should) specify errors. @annevk ? @domenic ? We throw SecurityError for some cases that violate security rules. Instead of AbortError for non-implemented features, maybe NotSupportedError? |
So you definitely need to specify the error type, and all browsers need to agree. There's no option of not specifying the error type at all. But you don't need to make sure every error type is used perfectly and maps to distinct cases, if developers don't need to distinguish between such cases. For example, you could just always throw a Specific error type guidance you should be consistent with, which is unfortunately not written down or consistently applied, is:
Note that " So yeah, there are some improvements you could make here to align better with the rest of the platform. |
I2S: https://groups.google.com/a/chromium.org/g/blink-dev/c/tESXuOfqQMQ Also creates a flag to disable this feature if needed, which would reject with a NotSupportedError (as suggested here: whatwg/fs#57) Bug: 1114923 Change-Id: I6568652a1e3e73f69017d5349a62d65971d61301 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4077526 Reviewed-by: Daseul Lee <[email protected]> Commit-Queue: Daseul Lee <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Mike Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#1083453}
This came up in web-platform-tests/wpt@b20e834#r85726061
Ideally API errors map uniquely to DOMExceptions, which make them actionable by the site. For example, if
NoModificationAllowedError
always indicates that a file is locked andNotAllowedError
always indicates the site needs torequestPermission()
on the handle, the site can respond differently to these errors.Currently, developers have to figure out this mapping on their own, or read the whole spec and infer this mapping. It would be nice to include a table mapping API errors to DOMExceptions that developers can use as a reference. Is there precedent for having this type of table in a spec?
That being said, it could be tricky to add a mapping that truly guarantees an error corresponds to a given API error (especially outside of the OPFS, where there's a whole host of things that could happen on the underlying OS). At the very least, here's a list of the mappings I'm aware of as a starting point...
NotAllowedError
requestPermission()
)NoModificationAllowedError
InvalidModificationError
move()
QuotaExceededError
TypeMismatchError
AbortError
move()
)InvalidStateError
Some errors are mostly relevant outside of the OPFS:
AbortError
(in addition to above)InvalidStateError
(in addition to above)SecurityError
The text was updated successfully, but these errors were encountered: