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 3 commits
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
25 changes: 21 additions & 4 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -14613,13 +14613,19 @@ The {{DOMException}} type is an [=interface type=] defined by the following IDL
fragment:

<pre class="idl">
dictionary DOMExceptionOptions {
any cause;
DOMString name = "Error";
};

[Exposed=*,
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 @@ -14655,19 +14661,28 @@ requirements beyond the normal ones for [=interface types=].
Each {{DOMException}} object has an associated <dfn export for="DOMException">name</dfn> and
<dfn export for="DOMException">message</dfn>, both [=strings=].

Each {{DOMException}} object has an associated <dfn for="DOMException">cause</dfn>, which
is a JavaScript value. It is <emu-val>undefined</emu-val> unless specified otherwise.

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. If |options|["{{DOMExceptionOptions/cause}}"] [=map/exists=], then set [=this=]'s [=DOMException/cause=] to |options|["{{DOMExceptionOptions/cause}}"].

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 <a><code>DOMException</code> names table</a> for [=this=]'s
[=DOMException/name=], or 0 if no such entry exists in the table.
Expand All @@ -14679,6 +14694,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 the [=sub-serialization=] of the value of <var>value</var>'s [=DOMException/cause=].</li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<li>Set <var>serialized</var>.\[[Cause]] to the [=sub-serialization=] of the value of <var>value</var>'s [=DOMException/cause=].</li>
<li>Set <var>serialized</var>.\[[Cause]] to the [=sub-serialization=] of <var>value</var>'s [=DOMException/cause=].</li>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed!

<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 @@ -14689,6 +14705,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 the [=sub-deserialization=] of the value of <var>serialized</var>.\[[Cause]].</li>
legendecas marked this conversation as resolved.
Show resolved Hide resolved
<li>If any other data is attached to <var>serialized</var>, then deserialize and attach it to
<var>value</var>.</li>
</ol>
Expand Down