From ac29130f454fc961f04bc9133b449771dc2f079e Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Fri, 11 Oct 2024 21:40:44 +0800 Subject: [PATCH] Add docs for `ErrorEvent.message` (#36280) * add * add a simple example --- files/en-us/web/api/errorevent/index.md | 2 +- .../en-us/web/api/errorevent/message/index.md | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 files/en-us/web/api/errorevent/message/index.md diff --git a/files/en-us/web/api/errorevent/index.md b/files/en-us/web/api/errorevent/index.md index 12d1e9e21a3e75e..d3fdd9bc7560fb5 100644 --- a/files/en-us/web/api/errorevent/index.md +++ b/files/en-us/web/api/errorevent/index.md @@ -21,7 +21,7 @@ The **`ErrorEvent`** interface represents events providing information related t _Also inherits properties from its parent {{domxref("Event")}}_. - {{domxref("ErrorEvent.message")}} {{ReadOnlyInline}} - - : A string containing a human-readable error message describing the problem. Lacking a [`crossorigin`](/en-US/docs/Web/HTML/Attributes/crossorigin) setting reduces error logging. + - : A string containing a human-readable error message describing the problem. - {{domxref("ErrorEvent.filename")}} {{ReadOnlyInline}} - : A string containing the name of the script file in which the error occurred. - {{domxref("ErrorEvent.lineno")}} {{ReadOnlyInline}} diff --git a/files/en-us/web/api/errorevent/message/index.md b/files/en-us/web/api/errorevent/message/index.md new file mode 100644 index 000000000000000..989c4dd369c96b6 --- /dev/null +++ b/files/en-us/web/api/errorevent/message/index.md @@ -0,0 +1,31 @@ +--- +title: "ErrorEvent: message property" +short-title: message +slug: Web/API/ErrorEvent/message +page-type: web-api-instance-property +browser-compat: api.ErrorEvent.message +--- + +{{APIRef("HTML DOM")}}{{AvailableInWorkers}} + +The **`message`** read-only property of the {{domxref("ErrorEvent")}} interface returns a string containing a human-readable error message describing the problem. + +## Value + +A string. + +## Examples + +```js +window.addEventListener("error", (ev) => { + console.log("The error message: " + ev.message); +}); +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}}