Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Add DOMException cause #1179

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -14559,13 +14559,20 @@ The {{DOMException}} type is an [=interface type=] defined by the following IDL
fragment:

<pre class="idl">

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;
Expand Down Expand Up @@ -14601,19 +14608,28 @@ requirements beyond the normal ones for [=interface types=].
Each {{DOMException}} object has an associated <dfn for="DOMException">name</dfn> and
<dfn for="DOMException">message</dfn>, both [=strings=].

Each {{DOMException}} object has an associated <dfn for="DOMException">cause</dfn>, which
is a JavaScript value. It is {{undefined}} unless specified otherwise.
legendecas marked this conversation as resolved.
Show resolved Hide resolved

The
<dfn constructor for="DOMException" lt="DOMException(message, name)"><code>new DOMException(|message|, |name|)</code></dfn>
<dfn constructor for="DOMException" lt="DOMException(message, options)"><code>new DOMException(|message|, |options|)</code></dfn>
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}}"].
legendecas marked this conversation as resolved.
Show resolved Hide resolved

The <dfn attribute for="DOMException"><code>name</code></dfn> getter steps are to return
[=this=]'s [=DOMException/name=].

The <dfn attribute for="DOMException"><code>message</code></dfn> getter steps are to
return [=this=]'s [=DOMException/message=].

The <dfn attribute for="DOMException"><code>cause</code></dfn> getter steps are to
return [=this=]'s [=DOMException/cause=].

The <dfn attribute for="DOMException"><code>code</code></dfn> 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.
Expand All @@ -14625,6 +14641,7 @@ Their [=serialization steps=], given <var>value</var> and <var>serialized</var>,
<ol>
<li>Set <var>serialized</var>.\[[Name]] to <var>value</var>'s [=DOMException/name=].</li>
<li>Set <var>serialized</var>.\[[Message]] to <var>value</var>'s [=DOMException/message=].</li>
<li>Set <var>serialized</var>.\[[Cause]] to <var>value</var>'s [=DOMException/cause=].</li>
<li>User agents should attach a serialized representation of any interesting accompanying data
which are not yet specified, notably the <code>stack</code> property, to
<var>serialized</var>.</li>
Expand All @@ -14635,6 +14652,7 @@ Their [=deserialization steps=], given <var>value</var> and <var>serialized</var
<ol>
<li>Set <var>value</var>'s [=DOMException/name=] to <var>serialized</var>.\[[Name]].</li>
<li>Set <var>value</var>'s [=DOMException/message=] to <var>serialized</var>.\[[Message]].</li>
<li>Set <var>value</var>'s [=DOMException/cause=] to <var>serialized</var>.\[[Cause]].</li>
<li>If any other data is attached to <var>serialized</var>, then deserialize and attach it to
<var>value</var>.</li>
</ol>
Expand Down