Favorites

JavaScript Error.prototype.cause Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Error.prototype.cause
JavaScript Error Instance propertyThis property is supported by all modern browsers.
Updated 28th November 2026

The cause property of an Error records the original error that led to it, so wrapped errors keep their underlying reason.

Description

The cause property holds the underlying reason for an error, set with the cause option: new Error(message, { cause: err }). It lets you throw a higher-level, more meaningful error without losing the original details, which consoles and logging tools can show together.

The cause can be any value, not only an error, so you can attach extra context such as the failing request. Browser consoles typically show the cause chain when logging the error, which makes tracking down the original problem much easier.

Before cause was added in 2021, libraries used their own property names, such as originalError, for the same purpose. The cause option works with all built-in error types and with subclasses that pass their options to super().

Syntax

error.cause

Value

The value given as the cause option, usually another error.

Example

function loadConfig() {
  try {
    return JSON.parse('{oops');
  } catch (err) {
    throw new Error('Could not load config', { cause: err });
  }
}
try { loadConfig(); } catch (e) {
  console.log(e.message, '<-', e.cause.name);
}

Browser Support

The following information will show you the current browser support for the Error.prototype.cause property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee