From d0b7e96e0a7e649a9379b73e6199fd1c1b317ebe Mon Sep 17 00:00:00 2001 From: legendecas Date: Sat, 13 Aug 2022 11:43:20 +0800 Subject: [PATCH 1/3] Add DOMException cause --- index.bs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/index.bs b/index.bs index 310cc987..a7672e85 100644 --- a/index.bs +++ b/index.bs @@ -14559,13 +14559,20 @@ The {{DOMException}} type is an [=interface type=] defined by the following IDL fragment:
+
+dictionary DOMExceptionOptions {
+  any cause;
+  DOMString name = "Error";
+};
+
 [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 (DOMExceptionOptions or DOMString) options = {});
   readonly attribute DOMString name;
   readonly attribute DOMString message;
   readonly attribute unsigned short code;
+  readonly attribute any cause;
 
   const unsigned short INDEX_SIZE_ERR = 1;
   const unsigned short DOMSTRING_SIZE_ERR = 2;
@@ -14601,12 +14608,18 @@ requirements beyond the normal ones for [=interface types=].
 Each {{DOMException}} object has an associated name and
 message, both [=strings=].
 
+Each {{DOMException}} object has an associated cause, which
+is a JavaScript value. It is {{undefined}} unless specified otherwise.
+
 The
-new DOMException(|message|, |name|)
+new DOMException(|message|, |options|)
 constructor steps are:
 
-1. Set [=this=]'s [=DOMException/name=] to |name|.
-1. Set [=this=]'s [=DOMException/message=] to |message|.
+1.  Set [=this=]'s [=DOMException/message=] to |message|.
+1.  If |options| is a string, then set [=this=]'s [=DOMException/name=] to |options|.
+1.  Otherwise,
+    1.  Set [=this=]'s [=DOMException/name=] to |options|["{{DOMExceptionOptions/name}}"].
+    1.  Set [=this=]'s [=DOMException/cause=] to |options|["{{DOMExceptionOptions/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.
@@ -14625,6 +14641,7 @@ Their [=serialization steps=], given value and serialized,
 
  1. Set serialized.\[[Name]] to value's [=DOMException/name=].
  2. Set serialized.\[[Message]] to value's [=DOMException/message=].
  3. +
  4. Set serialized.\[[Cause]] to value's [=DOMException/cause=].
  5. User agents should attach a serialized representation of any interesting accompanying data which are not yet specified, notably the stack property, to serialized.
  6. @@ -14635,6 +14652,7 @@ Their [=deserialization steps=], given value and serialized
  7. Set value's [=DOMException/name=] to serialized.\[[Name]].
  8. Set value's [=DOMException/message=] to serialized.\[[Message]].
  9. +
  10. Set value's [=DOMException/cause=] to serialized.\[[Cause]].
  11. If any other data is attached to serialized, then deserialize and attach it to value.
From bf3b9836a43d6361804ca4a9cb7e8a4e81b1015b Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Wed, 7 Sep 2022 09:29:17 +0000 Subject: [PATCH 2/3] fixup! Add DOMException cause --- index.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.bs b/index.bs index a7672e85..e5487384 100644 --- a/index.bs +++ b/index.bs @@ -14609,7 +14609,7 @@ Each {{DOMException}} object has an associated namemessage, both [=strings=]. Each {{DOMException}} object has an associated cause, which -is a JavaScript value. It is {{undefined}} unless specified otherwise. +is a JavaScript value. It is undefined unless specified otherwise. The new DOMException(|message|, |options|) @@ -14619,7 +14619,7 @@ constructor steps are: 1. If |options| is a string, then set [=this=]'s [=DOMException/name=] to |options|. 1. Otherwise, 1. Set [=this=]'s [=DOMException/name=] to |options|["{{DOMExceptionOptions/name}}"]. - 1. Set [=this=]'s [=DOMException/cause=] to |options|["{{DOMExceptionOptions/cause}}"]. + 1. If |options|["{{DOMExceptionOptions/cause}}"] [=map/exists=], then set [=this=]'s [=DOMException/cause=] to |options|["{{DOMExceptionOptions/cause}}"]. The name getter steps are to return [=this=]'s [=DOMException/name=]. @@ -14641,7 +14641,7 @@ Their [=serialization steps=], given value and serialized,
  1. Set serialized.\[[Name]] to value's [=DOMException/name=].
  2. Set serialized.\[[Message]] to value's [=DOMException/message=].
  3. -
  4. Set serialized.\[[Cause]] to value's [=DOMException/cause=].
  5. +
  6. Set serialized.\[[Cause]] to the [=sub-serialization=] of the value of value's [=DOMException/cause=].
  7. User agents should attach a serialized representation of any interesting accompanying data which are not yet specified, notably the stack property, to serialized.
  8. @@ -14652,7 +14652,7 @@ Their [=deserialization steps=], given value and serialized
  9. Set value's [=DOMException/name=] to serialized.\[[Name]].
  10. Set value's [=DOMException/message=] to serialized.\[[Message]].
  11. -
  12. Set value's [=DOMException/cause=] to serialized.\[[Cause]].
  13. +
  14. Set value's [=DOMException/cause=] to the [=sub-deserialization=] of the value of serialized.\[[Cause]].
  15. If any other data is attached to serialized, then deserialize and attach it to value.
From 0f950662254a7dcd0a52ef21c7727e29bf456b21 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Wed, 5 Jul 2023 14:37:08 +0800 Subject: [PATCH 3/3] fixup! --- index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index 56de2296..d1fbf3f0 100644 --- a/index.bs +++ b/index.bs @@ -14694,7 +14694,7 @@ Their [=serialization steps=], given value and serialized,
  1. Set serialized.\[[Name]] to value's [=DOMException/name=].
  2. Set serialized.\[[Message]] to value's [=DOMException/message=].
  3. -
  4. Set serialized.\[[Cause]] to the [=sub-serialization=] of the value of value's [=DOMException/cause=].
  5. +
  6. Set serialized.\[[Cause]] to the [=sub-serialization=] of value's [=DOMException/cause=].
  7. User agents should attach a serialized representation of any interesting accompanying data which are not yet specified, notably the stack property, to serialized.
  8. @@ -14705,7 +14705,7 @@ Their [=deserialization steps=], given value and serialized
  9. Set value's [=DOMException/name=] to serialized.\[[Name]].
  10. Set value's [=DOMException/message=] to serialized.\[[Message]].
  11. -
  12. Set value's [=DOMException/cause=] to the [=sub-deserialization=] of the value of serialized.\[[Cause]].
  13. +
  14. Set value's [=DOMException/cause=] to the [=sub-deserialization=] of serialized.\[[Cause]].
  15. If any other data is attached to serialized, then deserialize and attach it to value.