throw-error

1.0.0 • Public • Published

throw-error

Throws something if it’s an Error; otherwise returns it.

Installation

Requires Node.js 6.0.0 or above.

npm i throw-error

API

The module exports a single function.

Parameter

x (any): A value which may or may not be an Error object.

Return Value

Returns x only if it isn’t an Error.

Example

const throwError = require('throw-error')
 
throwError('not an error') // 'not an error'
throwError(new Error()) // Uncaught Error

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    7
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    7

Package Sidebar

Install

npm i throw-error

Weekly Downloads

7

Version

1.0.0

License

MIT

Unpacked Size

2.38 kB

Total Files

4

Last publish

Collaborators

  • lamansky