Throws something if it’s an Error; otherwise returns it.
npm install throw-errorThrows something if it’s an Error; otherwise returns it.
Requires Node.js 6.0.0 or above.
``bash`
npm i throw-error
The module exports a single function.
x (any): A value which may or may not be an Error object.
Returns x only if it isn’t an Error.
`javascript
const throwError = require('throw-error')
throwError('not an error') // 'not an error'
throwError(new Error()) // Uncaught Error
``