- From: Anne van Kesteren <notifications@github.com>
- Date: Fri, 02 Jun 2023 08:12:35 -0700
- To: whatwg/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/webidl/pull/1211/review/1457737340@github.com>
@annevk approved this pull request. Looks good modulo nits and question. > </blockquote> + + <p>Such additional context is most helpful to implementers when it is not immediately obvious + why the exception is being thrown, e.g., because there are many different steps in the algorithm + which throw a "{{SyntaxError}}" {{DOMException}}. In contrast, if your specification throws a + "{{NotAllowedError}}" {{DOMException}} immediately after checking if the user has provided + permission to use a given feature, it's fairly obvious what sort of message the implementation + should construct, and so specifying it is not necessary. ```suggestion ought to construct, and so specifying it is not necessary. ``` > @@ -5176,6 +5197,93 @@ over just using {{SyntaxError!!exception}} to refer to the {{DOMException}}. [[D </tbody> </table> +<h4 id="idl-DOMException-derived-interfaces">{{DOMException}} derived interfaces</h4> + +When an exception needs to carry additional programmatically-introspectable information, beyond what +can be provided with a {{DOMException}}'s [=DOMException/name=], specification authors can create an +[=interface=] which [=interface/inherits=] from {{DOMException}}. Such interfaces need to follow +certain rules, in order to have a predictable shape for developers. Specifically: + +* The [=identifier=] of the [=interface=] must end with <code>Error</code>, and must not be any + of the names in the <a><code>DOMException</code> names table</a>. +* The [=interface=] must have a [=constructor operation=] which sets the instance's + [=DOMException/name=] to the interface's [=identifier=]. +* Their [=constructor operation=] must take as its first parameter an [=optional argument|optional=] + {{DOMString}} named |message| defaulting to the empty string, and must set the instance's + [=DOMException/message=] to |message|. +* Their [=constructor operation=] should take as its second parameter a [=dictionary=] containing Is the switch from must to should intentional? > * <dfn exception>EvalError</dfn> * <dfn exception>RangeError</dfn> * <dfn exception>ReferenceError</dfn> * <dfn exception>TypeError</dfn> * <dfn exception>URIError</dfn> -These correspond to all of the ECMAScript [=ECMAScript/error objects=] -(apart from <l spec=ecmascript>{{SyntaxError}}</l> and {{Error}}, -which are deliberately omitted as they are reserved for use -by the ECMAScript parser and by authors, respectively). -The meaning of each [=simple exception=] matches -its corresponding error object in the -ECMAScript specification. +These correspond to all of the ECMAScript [=ECMAScript/error objects=] (apart from +<l spec=ecmascript>{{SyntaxError}}</l> and <l spec=ecmascript>{{Error}}</l>, which are deliberately Please either file a follow-up or address. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/webidl/pull/1211#pullrequestreview-1457737340 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/webidl/pull/1211/review/1457737340@github.com>
Received on Friday, 2 June 2023 15:12:41 UTC