Skip to content

Commit c482c69

Browse files
authored
Editorial: Change exceptions to be more precise - part 2
Fixes #63 These should have been fixed in #70 but clearly I missed some ¯\_(ツ)_/¯
1 parent c8da45d commit c482c69

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

index.bs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ Their [=deserialization steps=], given |serialized| and |value| are:
212212

213213
1. If |serialized|.\[[Origin]] is not [=same origin=] with
214214
|value|'s [=relevant settings object=]'s [=environment settings object/origin=],
215-
then throw a {{DataCloneError}}.
215+
then throw a "{{DataCloneError}}" {{DOMException}}.
216216
1. Set |value|'s [=FileSystemHandle/entry=] to |serialized|.\[[Entry]]
217217

218218
</div>
@@ -462,7 +462,7 @@ and its async iterator |iterator| are:
462462
[=file system entry/query access=] given "`read`".
463463

464464
1. If |access| is not "{{PermissionState/granted}}",
465-
throw a {{NotAllowedError}}.
465+
throw a "{{NotAllowedError}}" {{DOMException}}.
466466

467467
1. Set |iterator|'s <dfn for="FileSystemDirectoryHandle-iterator">past results</dfn> to an empty [=/set=].
468468

@@ -674,7 +674,7 @@ The <dfn method for=FileSystemDirectoryHandle>removeEntry(|name|, |options|)</df
674674

675675
Issue(11): Better specify what possible exceptions this could throw.
676676
1. [=/Resolve=] |result| with `undefined`.
677-
1. [=/Reject=] |result| with a {{NotFoundError}}.
677+
1. [=/Reject=] |result| with a "{{NotFoundError}}" {{DOMException}}.
678678
1. Return |result|.
679679

680680
</div>
@@ -1073,7 +1073,8 @@ Issue(35): Specify how Access Handles should react when reading from a file that
10731073
<div algorithm>
10741074
The <dfn method for=FileSystemSyncAccessHandle>read(|buffer|, {{FileSystemReadWriteOptions}}: |options|)</dfn> method steps are:
10751075

1076-
1. If [=this=].[=[[state]]=] is "`closed`", throw an {{InvalidStateError}}.
1076+
1. If [=this=].[=[[state]]=] is "`closed`", throw an "{{InvalidStateError}}"
1077+
{{DOMException}}.
10771078
1. Let |bufferSize| be |buffer|'s [=byte length=].
10781079
1. Let |fileContents| be [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s [=file entry/binary data=].
10791080
1. Let |fileSize| be |fileContents|'s [=byte sequence/length=].
@@ -1114,7 +1115,8 @@ The <dfn method for=FileSystemSyncAccessHandle>read(|buffer|, {{FileSystemReadWr
11141115
<div algorithm>
11151116
The <dfn method for=FileSystemSyncAccessHandle>write(|buffer|, {{FileSystemReadWriteOptions}}: |options|)</dfn> method steps are:
11161117

1117-
1. If [=this=].[=[[state]]=] is "`closed`", throw an {{InvalidStateError}}.
1118+
1. If [=this=].[=[[state]]=] is "`closed`", throw an "{{InvalidStateError}}"
1119+
{{DOMException}}.
11181120
1. Let |writePosition| be |options|["{{FileSystemReadWriteOptions/at}}"] if
11191121
|options|["{{FileSystemReadWriteOptions/at}}"] [=map/exists=]; otherwise
11201122
[=this=]'s [=FileSystemSyncAccessHandle/file position cursor=].
@@ -1137,7 +1139,8 @@ The <dfn method for=FileSystemSyncAccessHandle>write(|buffer|, {{FileSystemReadW
11371139
1. Set |tail| to a [=byte sequence=] containing the last
11381140
|oldSize| &minus; (|writePosition| + |bufferSize|) bytes of |fileContents|.
11391141
1. Let |newSize| be |head|'s [=byte sequence/length=] + |bufferSize| + |tail|'s [=byte sequence/length=].
1140-
1. If |newSize| &minus; |oldSize| exceeds the available [=storage quota=], throw a {{QuotaExceededError}}.
1142+
1. If |newSize| &minus; |oldSize| exceeds the available [=storage quota=],
1143+
throw a "{{QuotaExceededError}}" {{DOMException}}.
11411144
1. Set [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s [=file entry/binary data=] to the concatenation of |head|, the contents of |buffer| and |tail|.
11421145

11431146
Note: The mechanism used to access buffer's contents is left purposely vague.
@@ -1151,7 +1154,7 @@ The <dfn method for=FileSystemSyncAccessHandle>write(|buffer|, {{FileSystemReadW
11511154
1. Let |bytesWritten| be the number of bytes that were written from |buffer|.
11521155
1. Set [=this=]'s [=FileSystemSyncAccessHandle/file position cursor=] to |writePosition| + |bytesWritten|.
11531156
1. Return |bytesWritten|.
1154-
1. Otherwise throw an {{InvalidStateError}}.
1157+
1. Otherwise throw an "{{InvalidStateError}}" {{DOMException}}.
11551158
1. Set [=this=]'s [=FileSystemSyncAccessHandle/file position cursor=] to |writePosition| + |bufferSize|.
11561159
1. Return |bufferSize|.
11571160

@@ -1169,23 +1172,24 @@ The <dfn method for=FileSystemSyncAccessHandle>write(|buffer|, {{FileSystemReadW
11691172
<div algorithm>
11701173
The <dfn method for=FileSystemSyncAccessHandle>truncate(|newSize|)</dfn> method steps are:
11711174

1172-
1. If [=this=].[=[[state]]=] is "`closed`", throw an {{InvalidStateError}}.
1175+
1. If [=this=].[=[[state]]=] is "`closed`", throw an "{{InvalidStateError}}"
1176+
{{DOMException}}.
11731177
1. Let |fileContents| be a copy of [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s [=file entry/binary data=].
11741178
1. 1. Let |oldSize| be the [=byte sequence/length=] of [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s [=file entry/binary data=].
11751179
1. If the underlying file system does not support setting a file's size to
11761180
|newSize|, throw a {{TypeError}}.
11771181
1. If |newSize| is larger than |oldSize|:
1178-
1. If |newSize| &minus; |oldSize| exceeds the available [=storage quota=], throw a {{QuotaExceededError}}.
1182+
1. If |newSize| &minus; |oldSize| exceeds the available [=storage quota=], throw a "{{QuotaExceededError}}" {{DOMException}}.
11791183
1. Set [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s to a [=byte sequence=] formed by concatenating
11801184
|fileContents| with a [=byte sequence=]
11811185
containing |newSize| &minus; |oldSize| 0x00 bytes.
11821186
1. If the operations modifying the [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s [=file entry/binary data=] in the previous steps
1183-
failed, throw an {{InvalidStateError}}.
1187+
failed, throw an "{{InvalidStateError}}" {{DOMException}}.
11841188
1. Otherwise, if |newSize| is smaller than |oldSize|:
11851189
1. Set [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s to a [=byte sequence=] containing the first |newSize| bytes
11861190
in |fileContents|.
11871191
1. If the operations modifying the [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s [=file entry/binary data=] in the previous steps
1188-
failed, throw an {{InvalidStateError}}.
1192+
failed, throw an "{{InvalidStateError}}" {{DOMException}}.
11891193
1. If [=this=]'s [=FileSystemSyncAccessHandle/file position cursor=] is greater than |newSize|, then set [=FileSystemSyncAccessHandle/file position cursor=] to |newSize|.
11901194

11911195
</div>
@@ -1200,7 +1204,8 @@ The <dfn method for=FileSystemSyncAccessHandle>truncate(|newSize|)</dfn> method
12001204
<div algorithm>
12011205
The <dfn method for=FileSystemSyncAccessHandle>getSize()</dfn> method steps are:
12021206

1203-
1. If [=this=].[=[[state]]=] is "`closed`", throw an {{InvalidStateError}}.
1207+
1. If [=this=].[=[[state]]=] is "`closed`", throw an "{{InvalidStateError}}"
1208+
{{DOMException}}.
12041209
1. Return [=this=].[=FileSystemSyncAccessHandle/[[file]]=]'s [=file entry/binary data=]'s [=byte sequence/length=].
12051210

12061211
</div>
@@ -1281,7 +1286,7 @@ The <dfn method for=StorageManager>getDirectory()</dfn> method steps are:
12811286

12821287
1. Let |map| be the result of running [=obtain a local storage bottle map=]
12831288
with |environment| and `"fileSystem"`. If this returns failure,
1284-
return [=a promise rejected with=] a {{SecurityError}}.
1289+
return [=a promise rejected with=] a "{{SecurityError}}" {{DOMException}}.
12851290

12861291
1. If |map|["root"] does not [=map/exist=]:
12871292
1. Let |dir| be a new [=directory entry=] whose [=query access=] and [=request access=] algorithms

0 commit comments

Comments
 (0)