Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for ErrorEvent() constructor #36222

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions files/en-us/web/api/errorevent/errorevent/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: "ErrorEvent: ErrorEvent() constructor"
short-title: ErrorEvent()
slug: Web/API/ErrorEvent/ErrorEvent
page-type: web-api-constructor
browser-compat: api.ErrorEvent.ErrorEvent
---

{{APIRef("HTML DOM")}}{{AvailableInWorkers}}

The **`ErrorEvent()`** constructor creates a new {{domxref("ErrorEvent")}} object.

## Syntax

```js-nolint
new ErrorEvent(type)
new ErrorEvent(type, options)
```

### Parameters

- `type`
- : A string with the name of the event. It is case-sensitive.
- `options` {{optional_inline}}
- : An object that, _in addition of the properties defined in {{domxref("Event/Event", "Event()")}}_, can have the following properties:
- `message` {{optional_inline}}
- : A string containing a human-readable error message describing the problem.
- `filename` {{optional_inline}}
- : A string containing the name of the script file in which the error occurred.
- `lineno` {{optional_inline}}
- : An integer containing the line number of the script file on which the error occurred.
- `colno` {{optional_inline}}
- : An integer containing the column number of the script file on which the error occurred.
- `error` {{optional_inline}}
- : A JavaScript value, such as an {{jsxref("Error")}} or {{domxref("DOMException")}}, representing the error associated with this event.

### Return value

A new {{domxref("ErrorEvent")}} object.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
4 changes: 3 additions & 1 deletion files/en-us/web/api/errorevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ _Inherits methods from its parent {{domxref("Event")}}_.

## See also

- [Using web workers](/en-US/docs/Web/API/Web_Workers_API/Using_web_workers), most likely objects to raise such an event
- [Using web workers](/en-US/docs/Web/API/Web_Workers_API/Using_web_workers), most likely objects to raise such an event.
- {{domxref("Window")}}: {{domxref("Window/error_event", "error")}} event
- {{domxref("Navigation")}}: {{domxref("Navigation/navigateerror_event", "navigateerror")}} event