1.0.0 • Published 8 years ago

wrapperr v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

WrappErr

Make a burrito out of your errors.

Why?

This makes it easier to figure out where things happen, especially in large codebases.

For the code:

fs.readFile('./abc', function (error, data) {
	if (error) {
		throw new WrappErr(error, 'Could not read abc');
	}
});

On error, you would get an error.message with:

Could not read abc: ENOENT, open './abc'

And an error.stack that looks like:

Could not read abc: ENOENT, open './abc'
	ENOENT, open './abc'
		at fs.js:207:20
		at Object.oncomplete (fs.js:107:15)
	Could not read abc
		at /path/to/some/test.js:12:9

Of course, the idea is that you should be able to re-wrap already wrapped errors to get even more detailed and contextualised errors.

Install

npm install --save wrapperr

Other examples

See ./examples for more details.

License

MIT.