@gik/tools-thrower

0.1.12 • Public • Published

@gik/tools-thrower 0.1.12

Errors with pretty stack and customizable name. Part of our tools suite.

Contributors
Supported platforms
  • linux
  • darwin

Table of contents

  • thrower Errors with pretty stack and customizable name.

thrower

Errors with pretty stack and customizable name.

Parameters
subject string | Array | Error The message or an Error instance to beautify. When an array is sent, replace subject ALA printf. signature:[subject, ...replacements]
[name] string An identifier for the error instance. Default 'Error'
[throws] boolean If false, return error instance instead of throwing. Default true
Returns

Error - A custom error instance with a pretty stack.

Example
Thrower('test'); // A standard Error with prettified stack
Thrower(new TypeError('test2')); // Standard TypeError with prettified stack
Thrower('test3', 'TestError'); // Custom TestError with 'test3' as message
Thrower(['hola %s', 'mundo'], 'HelloError'); // HelloError with 'hola mundo' as message
const Err = Thrower('bad boy', 'CanineError', false); // Returns CanineError instance.

▲ Top


Dependencies (3)

Dev Dependencies (2)

Package Sidebar

Install

npm i @gik/tools-thrower

Homepage

gik.mx

Weekly Downloads

1

Version

0.1.12

License

MIT

Last publish

Collaborators

  • etor