← Back to release summary

self.reportError()

Category
JavaScript
Type
Chromium catches up
Status
Enabled by default (Chrome 95)
Intent stage
Shipped

Summary

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.

Standards & signals

Explainers: https://github.com/whatwg/console/issues/50

View on chromestatus.com