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

1.0.4 • Public • Published

parse-base-error

NPM Downloads

Install

yarn add parse-base-error
# or
npm i parse-base-error

Example

import { parseBaseError } from 'parse-base-error';

const foo = async () => {
    try {
        await Promise.reject(new Error('Hello world'));
    } catch (e) {
        throw parseBaseError(e, 'foo', { hello: 'world' });
    }
};
const bar = async () => {
    try {
        await foo();
    } catch (e) {
        const error = parseBaseError(e, 'bar', 'bar')
            .log(); // [ParsedBaseError 2022-11-28T13:11:54.942Z]->[foo]->[bar]: hello world [{"hello":"world"},"bar"]

        console.log(error.data); // [ { hello: 'world' }, 'bar' ]
    }
};

bar();

License

MIT

Package Sidebar

Install

npm i parse-base-error

Weekly Downloads

9

Version

1.0.4

License

MIT

Unpacked Size

23.5 kB

Total Files

36

Last publish

Collaborators

  • a1im