Specify error mappings #57
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 and NotAllowedError
always indicates the site needs to requestPermission()
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
- No permission at the API level (i.e. need to
requestPermission()
)
- No permission at the API level (i.e. need to
NoModificationAllowedError
- Cannot acquire a lock to the handle
- Handle lacks read or write permission at the OS level (for example, trying to get write permission on a read-only file). This should only be relevant outside of the OPFS
InvalidModificationError
- Attempting to overwrite a file via
move()
- Attempting to overwrite a file via
QuotaExceededError
- Operation will exceed quota
TypeMismatchError
- The handle type (file/dir) does not match what's on disk
AbortError
- Using a not-yet-launched feature (i.e. directory
move()
) - Some internal errors
- Using a not-yet-launched feature (i.e. directory
InvalidStateError
- Attempting to close an already-closed writable or SyncAccessHandle
- Some internal errors
Some errors are mostly relevant outside of the OPFS:
AbortError
(in addition to above)- Picker selection cancelled
- File save/move blocked by Safe Browsing
InvalidStateError
(in addition to above)- Trying to show a picker in a detached frame
SecurityError
- Trying to show picker in sandboxed iframe/opaque origin/third party context/without user gesture
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Issue actions