Skip to content

Commit

Permalink
Add self.reportError()
Browse files Browse the repository at this point in the history
This allows libraries to emulate the behavior of an exception thrown in an event listener callback.

Additional context: whatwg/console#50.

Tests: web-platform-tests/wpt#29738.

Co-authored-by: Domenic Denicola <d@domenic.me>
  • Loading branch information
annevk and domenic committed Jul 27, 2021
1 parent 3650a12 commit 97a1e58
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -91936,6 +91936,12 @@ document.querySelector("button").addEventListener("click", bound);

<h5 id="runtime-script-errors">Runtime script errors</h5>

<dl class="domintro">
<dt>self . <code subdfn data-x="dom-reportError">reportError</code>( <var>e</var> )</dt>
<dd><p>Dispatches an <code data-x="event-error">error</code> event at the global object for the
given value <var>e</var>, in the same fashion as an unhandled exception.</p></dd>
</dl>

<p w-dev>In various scenarios, the user agent can report an exception by firing an <code
data-x="event-error">error</code> event at the <code>Window</code>. If this event is not canceled,
then the error is considered not handled, and can be reported to the developer console.</p>
Expand Down Expand Up @@ -92031,6 +92037,10 @@ document.querySelector("button").addEventListener("click", bound);
have known problems. You can track future cleanup in this area in <a
href="https://github.com/whatwg/html/issues/958">issue #958</a>.</p>

<p>The <dfn method for="WindowOrWorkerGlobalScope"
data-x="dom-reportError"><code>reportError(<var>e</var>)</code></dfn> method steps are to
<span>report the exception</span> <var>e</var>.</p>

<p id="the-errorevent-interface">The <code>ErrorEvent</code> interface is defined as follows:</p>

<pre><code class="idl">[Exposed=(Window,Worker)]
Expand Down Expand Up @@ -95034,6 +95044,8 @@ interface mixin <dfn interface>WindowOrWorkerGlobalScope</dfn> {
readonly attribute boolean <span data-x="dom-isSecureContext">isSecureContext</span>;
readonly attribute boolean <span data-x="dom-crossOriginIsolated">crossOriginIsolated</span>;

undefined <span data-x="dom-reportError">reportError</span>(any e);

// base64 utility methods
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
ByteString <span data-x="dom-atob">atob</span>(DOMString data);
Expand Down

0 comments on commit 97a1e58

Please sign in to comment.