@askbills/service-errors
v1.0.1
Published
collection of errors from api
Downloads
8
Readme
Introduction
Handle api's errors.
Capabilities and Frameworks
|Capability|Module|
|------------------|-----------|
|Server Framework|hapi
as a web server|
|Dependence Framework|es6-error
an easily-extendable error for use with ES6 classes, boom
provides a set of utilities for returning HTTP errors, joi
an object schema validation, debug
a tiny JavaScript debugging utility modelled after Node.js core's debugging technique.|
|Coding Standard|eslint
identifying and reporting on patterns found in ECMAScript/JavaScript code completely pluggable, babel-eslint
support parsing ECMAScript for eslint|
|Testing Framework|chai
a BDD / TDD assertion library for node and browser, lab
nodejs test framework uses domains instead of uncaught exception and other global manipulation, nyc
command line interface support checking code coverage|
How to test
npm test
npm test:coverage
How to check lint
npm run lint
npm run lintFix
How to use
1. Install module.
npm install @askbills/service-errors --save
2. Create a service connection object with an `api` tag.
server.connection([
{
address: 'localhost',
port: 3000,
labels: ['api']
}
]);
3. Register `serviceErrors` with server.
const plugins = [
{
select: ['api'],
register: serviceErrors
}
];
server.register(plugins);
4. Return/throw an error if error's condition matched.
const error = new ServiceError('custom message', 'CUSTOM_ERROR', 7777));
reply(error); // or throw error