npm.io
1.1.6 • Published 7 months ago

@voiceflow/verror

Licence
MIT
Version
1.1.6
Deps
1
Size
6 kB
Vulns
0
Weekly
0

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])
Param Type Default Description
message string error message
[code] number 500 http error code
[data] any any extra data to attach to the error

Keywords