5.10. Firing an error event
To fire an error event at a request, run these steps:
Let event be the result of creating an event using
[Event](https://dom.spec.whatwg.org/#event)
.Set event’s
[type](https://dom.spec.whatwg.org/#dom-event-type)
attribute to “error
“.Set event’s
[bubbles](https://dom.spec.whatwg.org/#dom-event-bubbles)
and[cancelable](https://dom.spec.whatwg.org/#dom-event-cancelable)
attributes to true.Let transaction be request’s transaction.
Let legacyOutputDidListenersThrowFlag be initially false.
If transaction’s state is inactive, then set transaction’s state to active.
Dispatch event at request with legacyOutputDidListenersThrowFlag.
If transaction’s state is active, then:
If legacyOutputDidListenersThrowFlag is true, then run abort a transaction with transaction and a newly created “
[AbortError](https://heycam.github.io/webidl/#aborterror)
“[DOMException](https://heycam.github.io/webidl/#idl-DOMException)
and terminate these steps. This is done even if event’s canceled flag is false.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://heycam.github.io/webidl/#aborterror)
rather than request’s error, even if[preventDefault()](https://dom.spec.whatwg.org/#dom-event-preventdefault)
is never called.If event’s canceled flag is false, then run abort a transaction using transaction and request‘s error, and terminate these steps.
If transaction’s request list is empty, then run commit a transaction with transaction.