Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
93
93
91
15
93
15
Built-in object
Error.Error.options cause parameter

`options.cause` parameter

93
93
91
15
93
15
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 1 item(s)
Implementation note
  • Before version 125, default console logging for `Error` objects does not print the cause.
Notes 1 item(s)
Implementation note
  • Before version 125, default console logging for `Error` objects does not print the cause.
Notes 1 item(s)
Implementation note
  • Default console logging for `Error` objects does not print the cause.
Notes 1 item(s)
Implementation note
  • Before version 125, default console logging for `Error` objects does not print the cause.
Notes 1 item(s)
Implementation note
  • Default console logging for `Error` objects does not print the cause.

Syntax

JAVASCRIPT
try {
  const data = JSON.parse(invalidJson);
} catch (err) {
  throw new Error('Failed to load data', { cause: err });
}

// Access the original error via err.cause

Live demo

Error Cause option

Error Cause property in source. Error link.

PreviewFullscreen

Error-n. tracking

deepout in also cause cause specific.

PreviewFullscreen

traditional. side notation and. comparison

Cause use and in error. cause retain in.

PreviewFullscreen

Use cases

  • Using Error cause

    The cause data property of an Error instance indicates the specific original cause of the error.

Cautions

  • No specific concerns. Stable across all major browsers.

Accessibility

  • When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.