ErrorEvent: ErrorEvent() constructor

Note: This feature is available in Web Workers.

The ErrorEvent() constructor creates a new ErrorEvent object.

Syntax

js
new ErrorEvent(type)
new ErrorEvent(type, options)

Parameters

type

A string with the name of the event. It is case-sensitive.

options Optional

An object that, in addition of the properties defined in Event(), can have the following properties:

message Optional

A string containing a human-readable error message describing the problem.

filename Optional

A string containing the name of the script file in which the error occurred.

lineno Optional

An integer containing the line number of the script file on which the error occurred.

colno Optional

An integer containing the column number of the script file on which the error occurred.

error Optional

A JavaScript value, such as an Error or DOMException, representing the error associated with this event.

Return value

A new ErrorEvent object.

Specifications

Specification
HTML Standard
# errorevent

Browser compatibility

BCD tables only load in the browser