Skip to content

ErrorEvent ​

ErrorEvent represents an uncaught exception. It is the event object of the error event on application, and carries the thrown value, the name of the script that failed, and the line number.

Inheritance: Event → ErrorEvent

Constructor ​

ErrorEvent()

Creates an error event object. The runtime creates one itself when it fires error; app code rarely needs to.

Instance properties ​

Also inherits the properties of Event. For the error event the runtime fires, cancelable is true.

PropertyDescription
message read-onlyA short text summary of the error
error read-onlyThe value that was thrown
filename read-onlyThe name of the script that failed
lineno read-onlyThe line number where the error occurred

Examples ​

js
application.addEventListener('error', (e) => {
  console.log(e instanceof ErrorEvent, e.message);
  e.preventDefault();
});
throw new Error('Broken');

Result: prints true and the summary of the error.

See also ​