Skip to content

Commit

Permalink
Merge pull request #460 from jan-ivar/errors
Browse files Browse the repository at this point in the history
Align WebTransportError with guidance.
  • Loading branch information
jan-ivar authored Feb 14, 2023
2 parents d90cf90 + 213189c commit d45000e
Showing 1 changed file with 52 additions and 59 deletions.
111 changes: 52 additions & 59 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ urlPrefix: http://www.ecma-international.org/ecma-262/6.0/index.html; spec: ECMA
text: settled; url: sec-promise-objects
urlPrefix: https://heycam.github.io/webidl/; spec: WEBIDL
type: dfn
text: new DOMException(message, name); for:DOMException; url: dom-domexception-domexception
text: created; for:DOMException; url: dfn-create-exception
text: name; for:DOMException; url: domexception-name
text: message; for:DOMException; url: domexception-message
</pre>

# Introduction # {#introduction}
Expand Down Expand Up @@ -730,8 +732,8 @@ To <dfn>initialize WebTransport over HTTP</dfn>, given a {{WebTransport}} object
returns <b>blocked</b>, then abort the remaining steps and [=queue a network task=] with |transport|
to run these steps:
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, then abort these steps.
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"session"`.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"session"`.
1. [=Cleanup=] |transport| with |error|.
1. Let |networkPartitionKey| be the result of [=determining the network partition key=] with
|transport|'s [=relevant settings object=].
Expand All @@ -744,17 +746,17 @@ To <dfn>initialize WebTransport over HTTP</dfn>, given a {{WebTransport}} object
1. If |connection| is failure, then abort the remaining steps and [=queue a network task=] with
|transport| to run these steps:
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, then abort these steps.
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"session"`.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"session"`.
1. [=Cleanup=] |transport| with |error|.
1. Wait for |connection| to receive the first SETTINGS frame, and let |settings| be a dictionary that
represents the SETTINGS frame.
1. If |settings| doesn't contain SETTINGS_ENABLE_WEBTRANPORT with a value of 1, or it doesn't
contain H3_DATAGRAM with a value of 1, then abort the remaining steps and [=queue a network
task=] with |transport| to run these steps:
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, then abort these steps.
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"session"`.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"session"`.
1. [=Cleanup=] |transport| with |error|.
1. [=session/Establish=] a [=WebTransport session=] with |origin| on |connection|.

Expand All @@ -763,8 +765,8 @@ To <dfn>initialize WebTransport over HTTP</dfn>, given a {{WebTransport}} object
1. If the previous step fails, abort the remaining steps and [=queue a network task=] with
|transport| to run these steps:
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, then abort these steps.
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"session"`.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"session"`.
1. [=Cleanup=] |transport| with |error|.
1. Let |session| be the established [=WebTransport session=].
1. Assert: |maxDatagramSize| is an integer.
Expand Down Expand Up @@ -866,8 +868,8 @@ these steps.
1. Let |transport| be [=this=].
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, then abort these steps.
1. If |transport|.{{[[State]]}} is `"connecting"`:
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"session"`.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"session"`.
1. [=Cleanup=] |transport| with |error|.
1. Abort these steps.
1. Let |session| be |transport|.{{[[Session]]}}.
Expand Down Expand Up @@ -1011,8 +1013,8 @@ Whenever a [=WebTransport session=] which is associated with a {{WebTransport}}
request that initiated |transport|.{{[[Session]]}} is in the "Data Recvd" state. [[!QUIC]]
1. [=Queue a network task=] with |transport| to run these steps:
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, abort these steps.
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"session"`.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"session"`.
1. If |cleanly| is false, then [=cleanup=] |transport| with |error|, and abort these steps.
1. Let |closeInfo| be a [=new=] {{WebTransportCloseInfo}}.
1. If |code| is given, set |closeInfo|'s {{WebTransportCloseInfo/closeCode}} to |code|.
Expand All @@ -1028,8 +1030,8 @@ run these steps:

1. [=Queue a network task=] with |transport| to run these steps:
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, abort these steps.
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"session"`.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"session"`.
1. [=Cleanup=] |transport| with |error|.

</div>
Expand Down Expand Up @@ -1461,7 +1463,7 @@ To <dfn for="WebTransportSendStream">abort</dfn> a {{WebTransportSendStream}} |s
1. Let |promise| be a new promise.
1. Let |code| be 0.
1. [=set/Remove=] |stream| from |transport|.{{[[SendStreams]]}}.
1. If |reason| is a {{WebTransportError}} and |reasons|.{{WebTransportError/[[StreamErrorCode]]}} is not
1. If |reason| is a {{WebTransportError}} and |reason|.{{WebTransportError/[[StreamErrorCode]]}} is not
null, then set |code| to |reason|.{{WebTransportError/[[StreamErrorCode]]}}.
1. If |code| < 0, then set |code| to 0.
1. If |code| > 255, then set |code| to 255.
Expand Down Expand Up @@ -1490,9 +1492,9 @@ Whenever a [=WebTransport stream=] associated with a {{WebTransportSendStream}}
1. [=Queue a network task=] with |transport| to run these steps:
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, abort these steps.
1. [=set/Remove=] |stream| from |transport|.{{[[SendStreams]]}}.
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"stream"`.
1. Set |error|.{{WebTransportError/[[StreamErrorCode]]}} to |code|.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"stream"` and
{{WebTransportErrorOptions/streamErrorCode}} is |code|.
1. [=WritableStream/Error=] |stream| with |error|.

</div>
Expand Down Expand Up @@ -1683,7 +1685,7 @@ steps.
1. Let |internalStream| be |stream|.{{WebTransportReceiveStream/[[InternalStream]]}}.
1. Let |promise| be a new promise.
1. Let |code| be 0.
1. If |reason| is a {{WebTransportError}} and |reasons|.{{WebTransportError/[[StreamErrorCode]]}} is not
1. If |reason| is a {{WebTransportError}} and |reason|.{{WebTransportError/[[StreamErrorCode]]}} is not
null, then set |code| to |reason|.{{WebTransportError/[[StreamErrorCode]]}}.
1. If |code| < 0, then set |code| to 0.
1. If |code| > 255, then set |code| to 255.
Expand Down Expand Up @@ -1719,9 +1721,9 @@ Whenever a [=WebTransport stream=] associated with a {{WebTransportReceiveStream
1. [=Queue a network task=] with |transport| to run these steps:
1. If |transport|.{{[[State]]}} is `"closed"` or `"failed"`, abort these steps.
1. [=set/Remove=] |stream| from |transport|.{{[[ReceiveStreams]]}}.
1. Let |error| be the result of [=WebTransportError/creating=] a {{WebTransportError}} with
`"stream"`.
1. Set |error|.{{WebTransportError/[[StreamErrorCode]]}} to |code|.
1. Let |error| be a newly [=DOMException/created=] {{WebTransportError}} whose
{{WebTransportErrorOptions/source}} is `"stream"` and
{{WebTransportErrorOptions/streamErrorCode}} is |code|.
1. [=ReadableStream/Error=] |stream| with |error|.

</div>
Expand Down Expand Up @@ -1832,17 +1834,17 @@ object |transport|, and a |sendOrder|, run these steps.
- A reason for a client-initiated abort operation.

<pre class="idl">
[Exposed=(Window,Worker), SecureContext]
[Exposed=(Window,Worker), Serializable, SecureContext]
interface WebTransportError : DOMException {
constructor(optional WebTransportErrorInit init = {});
constructor(optional DOMString message = "", optional WebTransportErrorOptions options = {});

readonly attribute WebTransportErrorSource source;
readonly attribute octet? streamErrorCode;
};

dictionary WebTransportErrorInit {
[Clamp] octet streamErrorCode;
DOMString message;
dictionary WebTransportErrorOptions {
WebTransportErrorSource source = "stream";
[Clamp] octet? streamErrorCode = null;
};

enum WebTransportErrorSource {
Expand Down Expand Up @@ -1879,12 +1881,19 @@ A {{WebTransportError}} has the following internal slots.
<div algorithm>

The <dfn constructor for="WebTransportError"
lt="WebTransportError(init)">new WebTransportError(init)</dfn> constructor steps are:
lt="WebTransportError(message, options)">new WebTransportError(message, options)</dfn>
constructor steps are:

1. Let |error| be [=this=].
1. Let |message| be |init|.{{WebTransportErrorInit/message}} if it exists, and `""` otherwise.
1. [=WebTransportError/Set up=] |error| with |message| and `"stream"`.
1. Set |error|.{{WebTransportError/[[StreamErrorCode]]}} to |init|.{{WebTransportErrorInit/streamErrorCode}} if it exists.
1. Set |this|'s [=DOMException/name=] to `"WebTransportError"`.
1. Set |this|'s [=DOMException/message=] to |message|.
1. Set |this|'s internal slots as follows:
: {{WebTransportError/[[Source]]}}
:: |options|.{{WebTransportErrorOptions/source}}
: {{WebTransportError/[[StreamErrorCode]]}}
:: |options|.{{WebTransportErrorOptions/streamErrorCode}}

Note: This name does not have a mapping to a legacy code, so [=this=]'s {{DOMException/code}}
is 0.

</div>

Expand All @@ -1895,36 +1904,20 @@ lt="WebTransportError(init)">new WebTransportError(init)</dfn> constructor steps
: <dfn for="WebTransportError" attribute>streamErrorCode</dfn>
:: The getter steps are to return [=this=]'s {{WebTransportError/[[StreamErrorCode]]}}.

## Procedures ## {#web-transport-error-procedures}

<div algorithm>

To <dfn for="WebTransportError">create</dfn> a {{WebTransportError}} |error| with a
{{WebTransportErrorSource}} |source|, run these steps:

1. Let |message| be an [=implementation-defined=] string.
1. Let |error| be a [=new=] {{WebTransportError}}.
1. [=Set up=] |error| with |message| and |source|.
## Serialization ## {#web-transport-error-serialization}

</div>

<div algorithm>
{{WebTransportError}} objects are [=serializable objects=].
Their [=serialization steps=], given |value| and |serialized|, are:

To <dfn for="WebTransportError">set up</dfn> a {{WebTransportError}} |error| with a {{DOMString}}
|message| and a {{WebTransportErrorSource}} |source|, run these steps:

1. Set |error|'s internal slots as:
: {{WebTransportError/[[StreamErrorCode]]}}
:: null
: {{WebTransportError/[[Source]]}}
:: |source|
1. Run [=DOMException/new DOMException(message, name)=] constructor steps with |error|, |message|
and `"WebTransportError"`.
1. Run the {{DOMException}} [=serialization steps=] given |value| and |serialized|.
1. Set |serialized|.`[[Source]]` to |value|.{{WebTransportError/[[Source]]}}.
1. Set |serialized|.`[[StreamErrorCode]]` to |value|.{{WebTransportError/[[StreamErrorCode]]}}.

Note: This name does not have a mapping to a legacy code, so [=this=]'s {{DOMException/code}}
is 0.
Their [=deserialization steps=], given |serialized| and |value|, are:

</div>
1. Run the {{DOMException}} [=deserialization steps=] given |serialized| and |value|.
1. Set |value|.{{WebTransportError/[[Source]]}} to |serialized|.`[[Source]]`.
1. Set |value|.{{WebTransportError/[[StreamErrorCode]]}} |serialized|.`[[StreamErrorCode]]`.

# Protocol Mappings # {#protocol-mapping}

Expand Down

0 comments on commit d45000e

Please sign in to comment.