@voiceflow/verror
v1.1.3
Published
xtrct.io error class
Downloads
3,256
Maintainers
Keywords
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
Kind: global class
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 |