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

See discussion in https://github.com/whatwg/webidl/issues/1168#issuecomment-1183851493.

This also includes some updates to all exception creation and throwing, such as reflecting how messages are actually passed along in practice, or using Web IDL infrastructure to create DOMException instances instead of Construct()ing them.

It seems some places were already doing this sort of thing, such as https://w3c.github.io/webtransport/#web-transport-error-interface and I think some media thing. For WebTransport, it seems like they aren't violating the letter of the current spec since they were never throwing such `WebTransportError`s or treating them like exceptions, instead just passing them through streams machinery and so on. But I think it's a good idea to codify this.

Note that WebTransportError's constructor violates the proposal here of requiring such errors to always take a `message` as their first constructor argument. Not sure exactly what to do about that...

<!--
Thank you for contributing to the Web IDL Standard! Please describe the change you are making and complete the checklist below if your change is not editorial.
-->

- [ ] At least two implementers are interested (and none opposed):
   * Chrome has a spec being built that would directly use this.
   * I am hopeful other engines think this is a reasonable idea, e.g. based on the WebTransport precedent?
- [x] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * Nothing here is testable directly; we'd instead write tests for specific subclasses.
- [x] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * I don't think we need to preemptively do this; it would come along as part of the bugs for implementing such subclasses.

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)


<!--
    This comment and the below content is programmatically generated.
    You may add a comma-separated list of anchors you'd like a
    direct link to below (e.g. #idl-serializers, #idl-sequence):

    Don't remove this comment or modify anything below this line.
    If you don't want a preview generated for this pull request,
    just replace the whole of this comment's content by "no preview"
    and remove what's below.
-->
***

### :boom: Error: 500 Internal Server Error :boom: ###

[PR Preview](https://github.com/tobie/pr-preview#pr-preview) failed to build. _(Last tried on Oct 8, 2022, 1:06 PM UTC)_.

<details>
<summary>More</summary>


PR Preview relies on a number of web services to run. There seems to be an issue with the following one:

:rotating_light: [CSS Spec Preprocessor](https://api.csswg.org/bikeshed/) - CSS Spec Preprocessor is the web service used to build Bikeshed specs.

:link: [Related URL](https://api.csswg.org/bikeshed/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fwhatwg%2Fwebidl%2F7c9f053c75d1a76ba6507b0dd5c30d8607292eca%2Findex.bs&force=1&md-status=LS-PR&md-Text-Macro=PR-NUMBER%201211)



_If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please [file an issue](https://github.com/tobie/pr-preview/issues/new?title=Error%20not%20surfaced%20properly&body=See%20whatwg/webidl%231211.)._
</details>

You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/webidl/pull/1211

-- Commit Summary --

  * Allow DOMException subclasses to be used as exceptions

-- File Changes --

    M index.bs (279)

-- Patch Links --

https://github.com/whatwg/webidl/pull/1211.patch
https://github.com/whatwg/webidl/pull/1211.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/pull/1211
You are receiving this because you are subscribed to this thread.

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

Received on Saturday, 8 October 2022 13:06:39 UTC