format-throw

0.1.0 • Public • Published

format-throw

Build Status Coverage Status Dependency Status devDependency Status

NPM

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.

Package Sidebar

Install

npm i format-throw

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • fza