An ES-spec-compliant shim/polyfill/replacement for the .cause
property on all Error types that works as far down as ES3
This package implements the es-shim API “multi” interface. It works in an ES3-supported environment and complies with the proposed spec.
npm install --save error-cause
const assert = require('assert');
require('error-cause/auto');
try {
x();
} catch (e) {
const actual = new Error('a better message!', { cause: e });
assert(actual instanceof Error);
assert(actual.cause === e);
}
Clone the repo, npm install
, and run npm test