1.0.1 • Published 5 years ago

@itemsjs/errors v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

ItemsJS errors

NPM version NPM downloads

About

This is a standard error library to use within nodejs applications.

Installation

npm i @itemsjs/errors --save

Usage

const customErrors = require('@itemsjs/errors');

// Class mode

throw new customErrors.General('E_UNAUTHORIZED', 'You don\' have access to this resouce');

// Or extending any error

fs.readFile('path/to/file', (err) => {

    if(err) {

        err = new customErrors.General('E_ACCESS_DENIED', undefined, err);

        // do something with extended error
    }
});

And you're good to go!

License

MIT