Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. WorkerGlobalScope
  4. error

WorkerGlobalScope: error event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

Note: This feature is only available inWeb Workers.

Theerror event of theWorkerGlobalScope interface fires when an error occurs in the worker.

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("error", (event) => { })onerror = (message, filename, lineno, colno, error) => { }

Note:For historical reasons,onerror onWindow andWorkerGlobalScope objects is the only event handler property that receives more than one argument.

For more details about this, see the page for theerror event onWindow objects.

Event type

A genericEvent.

Example

The following code snippet shows anonerror handler set inside a worker:

js
self.onerror = () => {  console.log("There is an error inside your worker!");};

The same snippet, but usingaddEventListener():

js
self.addEventListener("error", () => {  console.log("There is an error inside your worker!");});

Specifications

Specification
HTML
# handler-workerglobalscope-onerror

Browser compatibility

See also

TheWorkerGlobalScope interface it belongs to.

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp