WorkerGlobalScope: error イベント
error
は WorkerGlobalScope
インターフェイスのイベントで、ワーカー内でエラーが発生したときに発行されます。
構文
このイベント名を addEventListener()
などのメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。
js
addEventListener("error", (event) => {});
onerror = (message, filename, lineno, colno, error) => {};
イベント型
一般的な Event
です。
例
以下のコードスニペットは、ワーカーの中に設定された onerror
ハンドラーを示しています。
js
self.onerror = () => {
console.log("There is an error inside your worker!");
};
同じスニペットで、 addEventListener()
を使用したものです。
js
self.addEventListener("error", () => {
console.log("There is an error inside your worker!");
});
仕様書
Specification |
---|
HTML # handler-workerglobalscope-onerror |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
関連情報
所属先の WorkerGlobalScope
インターフェイス。