Baseline Widely available
Note: This feature is only available in Web Workers.
The error
event of the WorkerGlobalScope
interface fires when an error occurs in the worker.
Use the event name in methods like addEventListener()
, or set an event handler property.
addEventListener("error", (event) => { })
onerror = (message, filename, lineno, colno, error) => { }
Note: For historical reasons, onerror
on Window
and WorkerGlobalScope
objects is the only event handler property that receives more than one argument.
For more details about this, see the page for the error
event on Window
objects.
A generic Event
.
The following code snippet shows an onerror
handler set inside a worker:
self.onerror = () => {
console.log("There is an error inside your worker!");
};
The same snippet, but using addEventListener()
:
self.addEventListener("error", () => {
console.log("There is an error inside your worker!");
});
Specifications Browser compatibility See also
The WorkerGlobalScope
interface it belongs to.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4