5.10. Firing an error event
To fire an error event at a request, the implementation must run these steps:
Let event be the result of creating an event using
[Event](https://www.w3.org/TR/dom41/#event)
.Set event’s
[type](https://www.w3.org/TR/dom41/#dom-event-type)
attribute to “error
“.Set event’s
[bubbles](https://www.w3.org/TR/dom41/#dom-event-bubbles)
and[cancelable](https://www.w3.org/TR/dom41/#dom-event-cancelable)
attributes to true.Let transaction be request’s transaction.
Let legacyOutputDidListenersThrowFlag be initially unset.
Set transaction’s active flag.
Dispatch event at request with legacyOutputDidListenersThrowFlag.
Unset transaction’s active flag.
If legacyOutputDidListenersThrowFlag is set, run the steps to abort a transaction with transaction and a newly created “
[AbortError](https://www.w3.org/TR/WebIDL-1/#aborterror)
“[DOMException](https://www.w3.org/TR/WebIDL-1/#idl-DOMException)
and terminate these steps. This is done even if the event’s canceled flag is not set.This means that if an error event is fired and any of the event handlers throw an exception, transaction’s
[error](#dom-idbtransaction-error)
property is set to an[AbortError](https://www.w3.org/TR/WebIDL-1/#aborterror)
rather than request’s error, even if[preventDefault()](https://www.w3.org/TR/dom41/#dom-event-preventdefault)
is never called.If the event’s canceled flag is not set, run the steps to abort a transaction using transaction and request‘s error.