Re: [whatwg/webidl] Allow DOMException subclasses to be used as exceptions (PR #1211)

@jan-ivar commented on this pull request.



> +        Their [=deserialization steps=], given |value| and |serialized|, are:
+
+        1. Run the {{DOMException}} [=deserialization steps=] given |value| and |serialized|.

Arguments are reversed on deserialize.
```suggestion
        Their [=deserialization steps=], given |serialized| and |value|, are:

        1. Run the {{DOMException}} [=deserialization steps=] with |serialized| and |value|.
```

> +        Their [=serialization steps=], given |value| and |serialized|, are:
+
+        1. Run the {{DOMException}} [=serialization steps=] given |value| and |serialized|.

Nit: not sure what best practice is, but it seems odd to me to use "given" both on the calling and receiving end of an algorithm. I'd expect "with" on the calling end, like [two lines down from here](https://dom.spec.whatwg.org/#set-the-canceled-flag).

```suggestion
        Their [=serialization steps=], given |value| and |serialized|, are:

        1. Run the {{DOMException}} [=serialization steps=] with |value| and |serialized|.
```

> +          readonly attribute unsigned long long errorCode;
+        };
+
+        dictionary ProtocolXErrorOptions {
+            required [EnforceRange] unsigned long long errorCode;
+        };
+    </pre>
+
+    Every <code>ProtocolXError</code> instance has an <dfn for="ProtocolXError">error code</dfn>,
+    a number.
+
+    <div algorithm="ProtocolXError constructor">
+        The <b><code>new ProtocolXError(|message|, |options|)</code></b> constructor steps are:
+
+        1.  Set [=this=]'s [=DOMException/name=] to "<code>ProtocolXError</code>".
+        1.  Set [=this=]'s [=DOMException/message=] to |message|.

Still, why can't we reference the[ DOMException constructor steps](https://webidl.spec.whatwg.org/#dom-domexception-domexception) (which already expects `this` to be set up) directly? E.g. [like this](https://pr-preview.s3.amazonaws.com/jan-ivar/webtransport/pull/460.html#dom-webtransporterror-webtransporterror): _"Run the [new DOMException(message, name)](https://heycam.github.io/webidl/#dom-domexception-domexception) constructor steps on [this](https://webidl.spec.whatwg.org/#this) with message and "WebTransportError"."_

I concede the constructor naming suggests perhaps constructors aren't intended to be referenced directly like this — the "new" in the name seems to imply an implicit memory allocation and assignment to [=this=]. Is that how it's to be read? — If so, I'm having trouble doing that as well elsewhere in the PR where I DO want the allocation: _"Return a new [WebTransportError()](https://pr-preview.s3.amazonaws.com/jan-ivar/webtransport/pull/460.html#dom-webtransporterror-webtransporterror) with message and options."_ (how can I put the args in the ())?

In lieu of that, I'm struggling to access [=DOMException/name=] which is different from {{DOMException/name}}. Will take any bikeshed help.

Sorry for dropping this request for PR help here.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/pull/1211#pullrequestreview-1267670489

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/pull/1211/review/1267670489@github.com>

Received on Tuesday, 24 January 2023 15:58:32 UTC