WorkerGlobalScope.onerror

The onerror property of the WorkerGlobalScope interface represents an EventHandler to be called when the error event occurs and bubbles through the Worker.

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 Status Comment
HTML Living Standard
The definition of 'WorkerGlobalScope.onerror' in that specification.
Living Standard

Browser compatibility

BCD tables only load in the browser

See also

The WorkerGlobalScope interface it belongs to.