Skip to content

Commit

Permalink
Create a 'report an exception' algorithm per whatwg#958.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyroman committed Jun 5, 2024
1 parent 4dc04bc commit 3cbfa3f
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion source
Original file line number Diff line number Diff line change
Expand Up @@ -105389,6 +105389,8 @@ new PaymentRequest(…); // Allowed to use
object">the environment settings object's global object</dfn>.</p></li>
</ul>

<p>A <span>global object</span> has an <dfn for="global object">in error reporting mode</dfn> boolean, which is initially false.</p>

<p>To <dfn data-x="creating a new realm" export id="creating-a-new-javascript-realm">create a new
realm</dfn> in an <span>agent</span> <var>agent</var>, optionally with instructions to create a
global object or a global <b>this</b> binding (or both), the following steps are taken:</p>
Expand Down Expand Up @@ -107661,6 +107663,36 @@ document.querySelector("button").addEventListener("click", bound);

<div w-nodev>

<!-- TODO(jbroman): legacy links for "report the exception" & "report an error"-->
<p>When the user agent is required to <dfn data-x="report an exception">report</dfn> an exception <var>exception</var> for a particular <span>global object</span> <var>global</var> and optional <span data-x="concept-script">script</span> <var>script</var>, it must run these steps:</p>

<ol>
<li>Let <var>notHandled</var> be true.</li>
<li><p>If <var>global</var> is not <span>in error reporting mode</span>, then:</p><ol>
<li>Set <var>global</var>'s <span>in error reporting mode</span> to true.</li>
<li><p>If <var>script</var> is a <span>classic script</span> and <var>script</var>'s <span>muted errors</span> is true, then set <var>message</var> to "<code data-x="">Script error.</code>", <var>urlString</var> to the empty string, <var>line</var> and <var>col</var> to 0, and <var>errorValue</var> to null.</p></li>
<li>
<p><!-- INSERT TRACKING-->Let <var>message</var>, <var>filename</var>, <var>line</var> and <var>col</var> be <span>implementation-defined</span> values derived from <var>exception</var>.</p>

<p class="note">Browsers implement behavior not specified here or in <ref>JAVASCRIPT</ref> to gather values which are helpful, including in unusual cases (e.g., <tt>eval</tt>). In the future, this might be specified in greater detail.</p>

</li>
<li>
<p>If <var>global</var> implements <code>EventTarget</code>, then set <var>notHandled</var> to the result of <span data-x="concept-event-fire">firing an event</span> named <code data-x="event-error">error</code> at <var>global</var>, using <code>ErrorEvent</code>, with the <code data-x="dom-Event-cancelable">cancelable</code> attribute initialized to true, the <code data-x="dom-ErrorEvent-message">message</code> attribute initialized to <var>message</var>, the <code data-x="dom-ErrorEvent-filename">filename</code> attribute initialized to <var>filename</var>, the <code data-x="dom-ErrorEvent-lineno">lineno</code> attribute initialized to <var>line</var>, the <code data-x="dom-ErrorEvent-colno">colno</code> attribute initialized to <var>col</var>, and the <code data-x="dom-ErrorEvent-error">error</code> attribute initialized to <var>exception</var>.</p>

<p class="note">Returning true in an event handler cancels the event per <span>the event handler processing algorithm</span>.</p>

</li>
<li>Set <var>global</var>'s <span>in error reporting mode</span> to false.</li>
</ol></li>
<li><p>If <var>notHandled</var> is true, then:</p><ol>
<li><p>If <var>global</var> implements <code>DedicatedWorkerGlobalScope</code>, <span>queue a task</span> <!-- on what task source? --> to run these steps:</p><ol>
<li><p>blah blah blah something about firing an event named error at the Worker object.</p></li>
</ol></li>
<li><p>Otherwise, the user agent may report <var>exception</var> to a developer console.</p></li>
</ol></li>
</ol>

<p>When the user agent is required to <dfn data-x="report the error">report an error</dfn> for a
particular <span data-x="concept-script">script</span> <var>script</var> with a particular
position <var>line</var>:<var>col</var>, using a particular target <var>target</var>, it must run these steps, after which the error is either <dfn
Expand All @@ -107671,7 +107703,7 @@ document.querySelector("button").addEventListener("click", bound);
<li><p>If <var>target</var> is <span>in error reporting mode</span>, then return; the error is <i
data-x="concept-error-nothandled">not handled</i>.</p></li>

<li><p>Let <var>target</var> be <dfn>in error reporting mode</dfn>.</p></li>
<li><p>Let <var>target</var> be <dfn>in error reporting modezzzz</dfn>.</p></li>

<li><p>
<!--INSERT TRACKING-->
Expand Down

0 comments on commit 3cbfa3f

Please sign in to comment.