5.10. Firing an error event

To fire an error event at a request, the implementation must run these steps:

  1. Let event be the result of creating an event using [Event](https://www.w3.org/TR/dom41/#event).

  2. Set event’s [type](https://www.w3.org/TR/dom41/#dom-event-type) attribute to “error“.

  3. 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.

  4. Let transaction be request’s transaction.

  5. Let legacyOutputDidListenersThrowFlag be initially unset.

  6. Set transaction’s active flag.

  7. Dispatch event at request with legacyOutputDidListenersThrowFlag.

  8. Unset transaction’s active flag.

  9. 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.

  10. If the event’s canceled flag is not set, run the steps to abort a transaction using transaction and request‘s error.