2.0.3 • Published 5 years ago

@roleup/rerror v2.0.3

Weekly downloads
20
License
MIT
Repository
github
Last release
5 years ago

rerror

roleup.io error class

Install

npm i -S @roleup/xerror

Use

const RError = require('@roleup/rerror');

// Throws error which inheirits from Error and has a default http code of 500 INTERNAL_SERVER_ERROR
const throws = () => { throw new RError('boom'); };

// Throw with a different http code
// XError.HTTP_STATUS is just the 'http-status' package
const throwsWithHttpError = () => { throw new RError('boom', RError.HTTP_STATUS.BAD_REQUEST); };

// Throw with special data
const throwsWithData = () => { throw new RError('boom', undefined, {foo: 'bar'}); };

RError

Kind: global class

new RError(message, code, data)

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

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago