This function, available in windows and workers, allows developers to report errors to the console and any global "error" event handlers, in the same way as an uncaught JavaScript exception. It is mainly useful for custom event-dispatching or callback-manipulating libraries.

Motivation

This allows library developers to report exceptions in the same way the browser does, which is useful when they need more custom control over running the callback. See https://esdiscuss.org/topic/a-way-of-explicitly-reporting-exceptions and https://github.com/whatwg/html/pull/1196#issuecomment-854177687 for examples.

Specification

Specification link


Final published standard: Recommendation, Living Standard, Candidate Recommendation, or similar final form

Status in Chromium

Blink>HTML>Script


Enabled by default (tracking bug)

Consensus & Standardization

After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.

Owner

Search tags

error, exception,

Last updated on 2021-09-16