Skip to content

fza/format-throw

Repository files navigation

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.

About

Throw errors with formatted messages and support for custom error classes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •