Skip to content

Commit 84c8eb0

Browse files
Ethan Arrowooddom96
authored andcommitted
add socketerror section
1 parent 4ad25e1 commit 84c8eb0

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

index.bs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ following circumstances:
135135
Whether the promise should resolve without the ReadableStream being read is up for discussion.
136136
</div>
137137

138-
It can also be rejected with an exception under the following circumstances:
138+
It can also be rejected with an [[#socket-error]] under the following circumstances:
139139

140-
* a socket connection could not be established, either because the address/port combo requested is
141-
blocked or due to a transient issue with the runtime
140+
* a socket connection could not be established, either because the address/port combo requested is blocked
141+
* due to a transient issue with the runtime
142142

143143
Cancelling the socket's ReadableStream and closing the socket's WritableStream does not resolve the
144144
`closed` promise.
@@ -215,11 +215,11 @@ The `connect` method performs the following steps:
215215
<li>A connection is established to the specified `SocketAddress` asynchronously.</li>
216216
<li>New {{Socket}} instance is created with each of its attributes initialised immediately.</li>
217217
<li>The created {{Socket}} instance is returned immediately.</li>
218-
<li>If the connection fails for any reason, the socket's `closed` promise is rejected with an exception describing why the connection failed.</li>
218+
<li>If the connection fails for any reason, the socket's `closed` promise is rejected with a [[#socket-error]] exception describing why the connection failed.</li>
219219
<li>The instance's {{ReadableStream}} and {{WritableStream}} streams can be used immediately.</li>
220220
</ol>
221221

222-
At any point during the creation of the {{Socket}} instance, `connect` may throw an exception. One
222+
At any point during the creation of the {{Socket}} instance, `connect` may throw a [[#socket-error]] exception. One
223223
case where this can happen is if the input address is incorrectly formatted.
224224
Errors which occur asynchronously- after the socket instance has been returned- must reject the
225225
socket's `closed` promise.
@@ -232,8 +232,18 @@ socket's `closed` promise.
232232
to avoid connecting to private services hosted locally (or on the server's LAN).
233233
</div>
234234

235+
SocketError {#socket-error}
236+
---------------------------
237+
238+
`SocketError` is an instance of {{TypeError}}. The error message should start with `"SocketError: "`.
235239

240+
For example,
241+
242+
```javascript
243+
throw new SocketError('connection failed');
244+
```
236245

246+
Should result in the following error: `Uncaught SocketError [TypeError]: SocketError: connection failed`.
237247

238248
`SocketOptions` dictionary
239249
---------------------------

0 commit comments

Comments
 (0)