Skip to content

Commit

Permalink
Editorial: change exceptions to be more precise
Browse files Browse the repository at this point in the history
Fixes #63.
  • Loading branch information
a-sully authored Nov 8, 2022
1 parent abad896 commit b0f0396
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ The <dfn method for=FileSystemFileHandle>getFile()</dfn> method steps are:
1. Let |access| be the result of running [=this=]'s [=FileSystemHandle/entry=]'s
[=entry/query access=] given "`read`".
1. If |access| is not "{{PermissionState/granted}}",
reject |result| with a {{NotAllowedError}} and abort.
reject |result| with a "{{NotAllowedError}}" {{DOMException}} and abort.
1. Let |entry| be [=this=]'s [=FileSystemHandle/entry=].
1. Let |f| be a new {{File}}.
1. Set |f|'s <a spec=FileAPI>snapshot state</a> to the current state of |entry|.
Expand Down Expand Up @@ -347,10 +347,10 @@ The <dfn method for=FileSystemFileHandle>createWritable(|options|)</dfn> method
[=entry/request access=] given "`readwrite`".
If that throws an exception, [=reject=] |result| with that exception and abort.
1. If |access| is not "{{PermissionState/granted}}",
reject |result| with a {{NotAllowedError}} and abort.
reject |result| with a "{{NotAllowedError}}" {{DOMException}} and abort.
1. Let |entry| be [=this=]'s [=FileSystemHandle/entry=].
1. Let |lockResult| be the result of [=file entry/lock/take|taking a lock=] with "`shared`" on |entry|.
1. If |lockResult| is false, [=reject=] |result| with a {{NoModificationAllowedError}} and abort.
1. If |lockResult| is false, [=reject=] |result| with a "{{NoModificationAllowedError}}" {{DOMException}} and abort.
1. Let |stream| be the result of [=create a new FileSystemWritableFileStream|creating a new FileSystemWritableFileStream=]
for |entry| in [=this=]'s [=relevant realm=].
1. If |options|.{{FileSystemCreateWritableOptions/keepExistingData}} is true:
Expand Down Expand Up @@ -389,12 +389,12 @@ The <dfn method for=FileSystemFileHandle>createSyncAccessHandle()</dfn> method s
[=entry/request access=] given "`readwrite`".
If that throws an exception, [=reject=] |result| with that exception and abort.
1. If |access| is not "{{PermissionState/granted}}",
reject |result| with a {{NotAllowedError}} and abort.
reject |result| with a "{{NotAllowedError}}" {{DOMException}} and abort.
1. Let |entry| be [=this=]'s [=FileSystemHandle/entry=].
1. If |entry| does not represent an [=/entry=] in an [=origin private file system=],
reject |result| with an {{InvalidStateError}} and abort.
reject |result| with an "{{InvalidStateError}}" {{DOMException}} and abort.
1. Let |lockResult| be the result of [=file entry/lock/take|taking a lock=] with "`exclusive`" on |entry|.
1. If |lockResult| is false, [=reject=] |result| with a {{NoModificationAllowedError}} and abort.
1. If |lockResult| is false, [=reject=] |result| with a "{{NoModificationAllowedError}}" {{DOMException}} and abort.
1. Let |handle| be the result of [=create a new FileSystemSyncAccessHandle|creating a new FileSystemSyncAccessHandle=]
for |entry| in [=this=]'s [=relevant realm=].
1. [=/Resolve=] |result| with |handle|.
Expand Down Expand Up @@ -476,7 +476,7 @@ and its async iterator |iterator|:
[=entry/query access=] given "`read`".

1. If |access| is not "{{PermissionState/granted}}",
reject |promise| with a {{NotAllowedError}} and return |promise|.
reject |promise| with a "{{NotAllowedError}}" {{DOMException}} and return |promise|.

1. Let |child| be an [=/entry=] in |directory|'s [=directory entry/children=],
such that |child|'s [=entry/name=] is not contained in |iterator|'s [=past results=],
Expand Down Expand Up @@ -539,15 +539,15 @@ The <dfn method for=FileSystemDirectoryHandle>getFileHandle(|name|, |options|)</
1. Let |access| be the result of running [=this=]'s [=FileSystemHandle/entry=]'s
[=entry/query access=] given "`read`".
1. If |access| is not "{{PermissionState/granted}}",
reject |result| with a {{NotAllowedError}} and abort.
reject |result| with a "{{NotAllowedError}}" {{DOMException}} and abort.

1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
1. If |child|'s [=entry/name=] equals |name|:
1. If |child| is a [=directory entry=]:
1. [=/Reject=] |result| with a {{TypeMismatchError}} and abort.
1. [=/Reject=] |result| with a "{{TypeMismatchError}}" {{DOMException}} and abort.
1. [=/Resolve=] |result| with a new {{FileSystemFileHandle}} whose [=FileSystemHandle/entry=] is |child| and abort.
1. If |options|.{{FileSystemGetFileOptions/create}} is false:
1. [=/Reject=] |result| with a {{NotFoundError}} and abort.
1. [=/Reject=] |result| with a "{{NotFoundError}}" {{DOMException}} and abort.
1. Let |child| be a new [=file entry=] whose [=query access=] and [=request access=] algorithms
are those of |entry|.
1. Set |child|'s [=entry/name=] to |name|.
Expand Down Expand Up @@ -600,15 +600,15 @@ The <dfn method for=FileSystemDirectoryHandle>getDirectoryHandle(|name|, |option
1. Let |access| be the result of running [=this=]'s [=FileSystemHandle/entry=]'s
[=entry/query access=] given "`read`".
1. If |access| is not "{{PermissionState/granted}}",
reject |result| with a {{NotAllowedError}} and abort.
reject |result| with a "{{NotAllowedError}}" {{DOMException}} and abort.

1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
1. If |child|'s [=entry/name=] equals |name|:
1. If |child| is a [=file entry=]:
1. [=/Reject=] |result| with a {{TypeMismatchError}} and abort.
1. [=/Reject=] |result| with a "{{TypeMismatchError}}" {{DOMException}} and abort.
1. [=/Resolve=] |result| with a new {{FileSystemDirectoryHandle}} whose [=FileSystemHandle/entry=] is |child| and abort.
1. If |options|.{{FileSystemGetFileOptions/create}} is false:
1. [=/Reject=] |result| with a {{NotFoundError}} and abort.
1. [=/Reject=] |result| with a "{{NotFoundError}}" {{DOMException}} and abort.
1. Let |child| be a new [=directory entry=] whose [=query access=] and [=request access=]
algorithms are those of |entry|.
1. Set |child|'s [=entry/name=] to |name|.
Expand Down Expand Up @@ -654,13 +654,13 @@ The <dfn method for=FileSystemDirectoryHandle>removeEntry(|name|, |options|)</df
[=entry/request access=] given "`readwrite`".
If that throws an exception, [=reject=] |result| with that exception and abort.
1. If |access| is not "{{PermissionState/granted}}",
reject |result| with a {{NotAllowedError}} and abort.
reject |result| with a "{{NotAllowedError}}" {{DOMException}} and abort.

1. [=set/For each=] |child| of |entry|'s [=directory entry/children=]:
1. If |child|'s [=entry/name=] equals |name|:
1. If |child| is a [=directory entry=]:
1. If |child|'s [=directory entry/children=] is not [=set/is empty|empty=] and |options|.{{FileSystemRemoveOptions/recursive}} is false:
1. [=/Reject=] |result| with an {{InvalidModificationError}} and abort.
1. [=/Reject=] |result| with an "{{InvalidModificationError}}" {{DOMException}} and abort.
1. [=set/Remove=] |child| from |entry|'s [=directory entry/children=].
1. If removing |child| in the underlying file system throws an exception,
[=/reject=] |result| with that exception and abort.
Expand Down Expand Up @@ -797,9 +797,9 @@ in a [=/Realm=] |realm|, run these steps:
1. Run these steps [=in parallel=]:
1. Let |access| be the result of running |file|'s [=entry/query access=] given "`readwrite`".
1. If |access| is not "{{PermissionState/granted}}",
reject |closeResult| with a {{NotAllowedError}} and abort.
reject |closeResult| with a "{{NotAllowedError}}" {{DOMException}} and abort.
1. Run [=implementation-defined=] malware scans and safe browsing checks.
If these checks fail, [=/reject=] |closeResult| with an {{AbortError}} and abort.
If these checks fail, [=/reject=] |closeResult| with an "{{AbortError}}" {{DOMException}} and abort.
1. Set |stream|.[=FileSystemWritableFileStream/[[file]]=]'s [=file entry/binary data=] to |stream|.[=[[buffer]]=].
If that throws an exception, [=/reject=] |closeResult| with that exception and abort.

Expand Down Expand Up @@ -835,7 +835,7 @@ runs these steps:
1. Let |access| be the result of running |stream|'s [=FileSystemWritableFileStream/[[file]]=]'s
[=entry/query access=] given "`readwrite`".
1. If |access| is not "{{PermissionState/granted}}",
reject |p| with a {{NotAllowedError}} and abort.
reject |p| with a "{{NotAllowedError}}" {{DOMException}} and abort.
1. Let |command| be |input|.{{WriteParams/type}} if |input| is a {{WriteParams}},
and {{WriteCommandType/"write"}} otherwise.
1. If |command| is {{WriteCommandType/"write"}}:
Expand Down Expand Up @@ -871,7 +871,7 @@ runs these steps:
|oldSize| - (|writePosition| + |data|.[=byte sequence/length=]) bytes of |stream|.[=[[buffer]]=].
1. Set |stream|.[=[[buffer]]=] to the concatenation of |head|, |data| and |tail|.
1. If the operations modifying |stream|.[=[[buffer]]=] in the previous steps failed
due to exceeding the [=storage quota=], [=/reject=] |p| with a {{QuotaExceededError}} and abort,
due to exceeding the [=storage quota=], [=/reject=] |p| with a "{{QuotaExceededError}}" {{DOMException}} and abort,
leaving |stream|.[=[[buffer]]=] unmodified.

Note: [=Storage quota=] only applies to files stored in the [=origin private file system=].
Expand All @@ -893,7 +893,7 @@ runs these steps:
1. Set |stream|.[=[[buffer]]=] to a [=byte sequence=] formed by concating
|stream|.[=[[buffer]]=] with a [=byte sequence=] containing |newSize|-|oldSize| `0x00` bytes.
1. If the operation in the previous step failed due to exceeding the [=storage quota=],
[=/reject=] |p| with a {{QuotaExceededError}} and abort,
[=/reject=] |p| with a "{{QuotaExceededError}}" {{DOMException}} and abort,
leaving |stream|.[=[[buffer]]=] unmodified.

Note: [=Storage quota=] only applies to files stored in the [=origin private file system=].
Expand Down

0 comments on commit b0f0396

Please sign in to comment.