README
verror
Voiceflow error class
Install
npm i -S @voiceflow/verror
Use
const VError = require('@voiceflow/verror');
// Throws error which inheirits from Error and has a default http code of 500 INTERNAL_SERVER_ERROR
const throws = () => { throw new VError('boom'); };
// Throw with a different http code
// VError.HTTP_STATUS is just the 'http-status' package
const throwsWithHttpError = () => { throw new VError('boom', VError.HTTP_STATUS.BAD_REQUEST); };
// Throw with special data
const throwsWithData = () => { throw new VError('boom', undefined, {foo: 'bar'}); };
verror
new verror(message, [code], [data])
Param | Type | Default | Description |
---|---|---|---|
message | string |
error message | |
[code] | number |
500 |
http error code |
[data] | any |
any extra data to attach to the error |