Next Popular Module

    error-cause
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/error-cause package

    1.0.5 • Public • Published

    error-cause Version Badge

    github actions coverage dependency status dev dependency status License Downloads

    npm badge

    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.

    Getting started

    npm install --save error-cause

    Usage/Examples

    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);
    }

    Tests

    Clone the repo, npm install, and run npm test

    Install

    npm i error-cause

    DownloadsWeekly Downloads

    981

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    30.9 kB

    Total Files

    56

    Last publish

    Collaborators

    • ljharb