WorkerGlobalScope.onerror

The onerror property of the WorkerGlobalScope interface represents an event handler to be called when the error event occurs.

Syntax

self.onerror = function() { ... };

Example

The following code snippet shows an onerror handler set inside a worker:

self.onerror = function() {
  console.log('There is an error inside your worker!');
}

Specifications

Specification
HTML Standard (HTML)
# handler-workerglobalscope-onerror

Browser compatibility

BCD tables only load in the browser

See also

The WorkerGlobalScope interface it belongs to.