chained-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

chained-error

npm minified size minified & gziped size

Zero dependencies error that allows creating a chain of errors, preserving the original cause (with TypeScript support)

Install

Install with npm:

$ npm install --save chained-error

Basic usage

import ChainedError from 'chained-error';
 
// ...
try {
    // ...
} catch (error) {
    throw new ChainedError('My message', error);
}

Later, when you catch the error, and you print it, you will see something like it:

ChainedError: My message
    at ...
    at ...
    at ...
Caused By: TheOtherErrorType: The other error message
    at ...
    at ...
    at ...

Type definition

export default class ChainedError extends Error {
    cause: any;
    constructor(messageOrCause: any);
    constructor(message: string, cause: any);
}

License

MIT

/chained-error/

    Package Sidebar

    Install

    npm i chained-error

    Weekly Downloads

    2,202

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    6.09 kB

    Total Files

    7

    Last publish

    Collaborators

    • juanluispaz