format-throw
v0.1.0
Published
Throw errors with formatted msgs and support for custom error classes
Downloads
8
Readme
format-throw
Tiny utility to throw errors with formatted messages and support for custom error classes.
Installation
npm install --save format-throw
Usage
var thr = require('format-throw');
// Throw a TypeError
thr(TypeError, '%s is not %s', 'foo', 'bar');
// Throw a default Error
thr('The meaning of life is %d', 42);
// Return the error instance instead of throwing it
var err1 = thr.make(TypeError, 'meaningOfLife should be %d', '42');
var err2 = thr.make("Inked %s ain't %s", 'donkeys', 'zebras');
Contributing
Take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt test
.
License
Copyright (c) 2015 Felix Zandanel
Licensed under the MIT license.
See LICENSE for more info.