Skip to content

alessioalex/custom-err

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

custom-err

Easily create an error object with custom properties attached.

API

Err(message, properties)

Usage

var Err    = require('custom-err'),
    assert = require('assert');

// the first argument represents the error message
// the second argument represents the custom properties object
var myErr = Err('NotFound', { code: 404 });

assert.equal(myErr.message, 'NotFound');
assert.equal(myErr.code, 404);

Why?

Because I found myself often writing code like this:

var err = new Error('Not Found');
err.code = 404;
err.someProperty = true;

License

MIT

About

Create an error with custom properties in Node.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published