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
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.
| Property | Description |
|---|---|
message read-only | A short text summary of the error |
error read-only | The value that was thrown |
filename read-only | The name of the script that failed |
lineno read-only | The 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.