Skip to content

Commit

Permalink
Support structured serialization of AggregateErrors
Browse files Browse the repository at this point in the history
Closes #5716.
  • Loading branch information
domenic committed Jul 21, 2020
1 parent d033d58 commit de9bc6e
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions source
Expand Up @@ -2764,6 +2764,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://tc39.es/ecma262/#sec-well-known-intrinsic-objects">Well-Known Intrinsic Objects</dfn>, including
<dfn data-x-href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object">%Array.prototype%</dfn>,
<dfn data-x-href="https://tc39.es/ecma262/#sec-properties-of-the-error-prototype-object">%Error.prototype%</dfn>,
<dfn data-x-href="https://tc39.es/ecma262/#sec-properties-of-the-aggregate-error-prototype-objects">%AggregateError.prototype%</dfn>,
<dfn>%EvalError.prototype%</dfn>,
<dfn data-x-href="https://tc39.es/ecma262/#sec-properties-of-the-function-prototype-object">%Function.prototype%</dfn>,
<dfn data-x-href="https://tc39.es/ecma262/#sec-json.parse">%JSON.parse%</dfn>,
Expand Down Expand Up @@ -8143,8 +8144,8 @@ interface <dfn>DOMStringList</dfn> {
<li><p>Let <var>name</var> be ? <span data-x="js-Get">Get</span>(<var>value</var>,
"name").</p></li>

<li><p>If <var>name</var> is not one of "Error", "EvalError", "RangeError", "ReferenceError",
"SyntaxError", "TypeError", or "URIError", then set <var>name</var> to "Error".</p></li>
<li><p>If <var>name</var> is not one of "AggregateError", "Error", "EvalError", "RangeError",
"ReferenceError", "SyntaxError", "TypeError", or "URIError", then set <var>name</var> to

<li><p>Let <var>valueMessageDesc</var> be ? <var>value</var>.[[GetOwnProperty]]("<code
data-x="">message</code>").</p></li>
Expand All @@ -8153,8 +8154,24 @@ interface <dfn>DOMStringList</dfn> {
<span>IsDataDescriptor</span>(<var>valueMessageDesc</var>) is false, and
? <span>ToString</span>(<var>valueMessageDesc</var>.[[Value]]) otherwise.</p></li>

<li><p>Let <var>errors</var> be undefined.</p></li>

<li>
<p>If <var>name</var> is "AggregateError", then:</p>

<ol>
<li><p>Let <var>errorsDesc</var> be ? <var>value</var>.[[GetOwnProperty]]("<code
data-x="">errors</code>").</p></li>

<li><p>If <span>IsDataDescriptor</span>(<var>errorsDesc</var>) is true, then set
<var>errors</var> to ?
<span>StructuredSerializeInternal</span>(<var>errorsDesc</var>.[[Value]],
<var>forStorage</var>, <var>memory</var>).</p></li>
</ol>
</li>

<li><p>Set <var>serialized</var> to { [[Type]]: "Error", [[Name]]: <var>name</var>,
[[Message]]: <var>message</var> }.</p></li>
[[Message]]: <var>message</var>, [[Errors]]: <var>errors</var> }.</p></li>

<li>
<p>User agents should attach a serialized representation of any interesting accompanying
Expand Down Expand Up @@ -8557,6 +8574,9 @@ o.myself = o;</code></pre>
<ol>
<li><p>Let <var>prototype</var> be <span>%Error.prototype%</span>.</p></li>

<li><p>If <var>serialized</var>.[[Name]] is "AggregateError", then set <var>prototype</var> to
<span>%AggregateError.prototype%</span>.</p></li>

<li><p>If <var>serialized</var>.[[Name]] is "EvalError", then set <var>prototype</var> to
<span>%EvalError.prototype%</span>.</p></li>

Expand All @@ -8575,11 +8595,11 @@ o.myself = o;</code></pre>
<li><p>If <var>serialized</var>.[[Name]] is "URIError", then set <var>prototype</var> to
<span>%URIError.prototype%</span>.</p></li>

<li><p>Let <var>message</var> be <var>serialized</var>.[[Message]].</p></li>

<li><p>Set <var>value</var> to ! <span>ObjectCreate</span>(<var>prototype</var>, «
[[ErrorData]] »).</p></li>

<li><p>Let <var>message</var> be <var>serialized</var>.[[Message]].</p></li>

<li><p>Let <var>messageDesc</var> be <span>PropertyDescriptor</span>{ [[Value]]:
<var>message</var>, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true
}.</p></li>
Expand All @@ -8588,6 +8608,16 @@ o.myself = o;</code></pre>
<span>OrdinaryDefineOwnProperty</span>(<var>value</var>, "<code data-x="">message</code>",
<var>messageDesc</var>).</p></li>

<li><p>Let <var>errors</var> be <var>serialized</var>.[[Errors]].</p></li>

<li><p>Let <var>errorsDesc</var> be <span>PropertyDescriptor</span>{ [[Value]]:
<var>errors</var>, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true
}.</p></li>

<li><p>If <var>errors</var> is not undefined, then perform !
<span>OrdinaryDefineOwnProperty</span>(<var>value</var>, "<code data-x="">errors</code>",
<var>errorsDesc</var>).</p></li>

<li><p>Any interesting accompanying data attached to <var>serialized</var> should be
deserialized and attached to <var>value</var>.</p></li>
</ol>
Expand Down

0 comments on commit de9bc6e

Please sign in to comment.