--- title: EventSource.onerror slug: Web/API/EventSource/onerror tags: - API - EventSource - Server-sent events - イベントハンドラ - プロパティ - リファレンス translation_of: Web/API/EventSource/onerror ---
{{domxref("EventSource")}} インターフェースのonerror プロパティは、エラーが発生し、EventSource オブジェクトに対して {{event("error")}} が送出されたときに呼び出される {{event("Event_handlers", "event handler")}} です。
eventSource.onerror = function
evtSource.onerror = function() {
console.log("EventSource failed.");
};
メモ: 完全な例を GitHub から見つけることができます — PHP を用いた簡単な SSE のデモ を参照。
| 仕様 | ステータス | コメント |
|---|---|---|
| {{SpecName('HTML WHATWG', "comms.html#handler-eventsource-onerror", "onerror")}} | {{Spec2('HTML WHATWG')}} | 初期定義 |
{{Compat("api.EventSource.onerror")}}