From 567cfc94b9f54ce2259b72df2d927cf2cfced376 Mon Sep 17 00:00:00 2001 From: legendecas Date: Sat, 13 Aug 2022 11:43:20 +0800 Subject: [PATCH] Add DOMException cause --- index.bs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/index.bs b/index.bs index 310cc9878..127f6a0aa 100644 --- a/index.bs +++ b/index.bs @@ -14559,12 +14559,19 @@ The {{DOMException}} type is an [=interface type=] defined by the following IDL fragment:
+
+dictionary DOMExceptionOptions {
+  any cause;
+  DOMString name;
+};
+
 [Exposed=(Window,Worker),
  Serializable]
 interface DOMException { // but see below note about ECMAScript binding
-  constructor(optional DOMString message = "", optional DOMString name = "Error");
+  constructor(optional DOMString message = "", optional (DOMString or DOMExceptionOptions) nameOrOptions = "Error");
   readonly attribute DOMString name;
   readonly attribute DOMString message;
+  readonly attribute any cause;
   readonly attribute unsigned short code;
 
   const unsigned short INDEX_SIZE_ERR = 1;
@@ -14598,15 +14605,21 @@ interface DOMException { // but see below note about ECMAScript binding
 Note: as discussed in [[#es-DOMException-specialness]], the ECMAScript binding imposes additional
 requirements beyond the normal ones for [=interface types=].
 
-Each {{DOMException}} object has an associated name and
-message, both [=strings=].
+Each {{DOMException}} object has associated fields:
+
+*   its name, which is [=strings=],
+*   its message, which is [=strings=],
+*   its cause, which is {{any}} value.
 
 The
-new DOMException(|message|, |name|)
+new DOMException(|message|, |nameOrOptions|)
 constructor steps are:
 
-1. Set [=this=]'s [=DOMException/name=] to |name|.
 1. Set [=this=]'s [=DOMException/message=] to |message|.
+1. If |nameOrOptions| is a string, set [=this=]'s [=DOMException/name=] to |nameOrOptions|.
+1. Else,
+    1. If |nameOrOptions|'name is present, set [=this=]'s [=DOMException/name=] to |nameOrOptions|'s name, else set [=this=]'s [=DOMException/name=] to "Error".
+    1. If |nameOrOptions|'cause is present, set [=this=]'s [=DOMException/cause=] to |nameOrOptions|'s cause.
 
 The name getter steps are to return
 [=this=]'s [=DOMException/name=].
@@ -14614,6 +14627,9 @@ The name getter steps are t
 The message getter steps are to
 return [=this=]'s [=DOMException/message=].
 
+The cause getter steps are to
+return [=this=]'s [=DOMException/cause=].
+
 The code getter steps are to return the legacy
 code indicated in the [=error names table=] for [=this=]'s [=DOMException/name=], or 0 if no such
 entry exists in the table.