1.1.3 • Published 3 years ago

@voiceflow/verror v1.1.3

Weekly downloads
264
License
MIT
Repository
github
Last release
3 years ago

circle ci Coverage Quality Gate Status

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)

ParamTypeDefaultDescription
messagestringerror message
codenumber500http error code
dataanyany extra data to attach to the error