error-naturals
Version:
62 lines (44 loc) • 1.52 kB
Markdown
>
```sh
$ npm install --save error-naturals
$ yarn add error-naturals
```
```js
const ErrorNaturals = require('error-naturals');
const path = require('path');
const errorNaturals = new ErrorNaturals(path.join(__dirname, PATH_TO_YOUR_ERROR_CONFIG_JSON_FILE ));
errorNaturals.generateErrors(errorCode,errorType,customMessage, customResponse);
```
You need to create a json file in the following format.
```json
{
"YOUR_ERROR_CODE": {
"error": {
"meta": {
"type": "error",
"status": 400,
"code": "INVALID_REQUEST",
"context_info": {
"ping": {
"message": "A ping request was made without revelant content"
}
},
"help_url": "http://developers.hootboard.com/docs/#errors",
"message": "A ping request was made without one or more required parameters"
}
}
}
}
```
MIT © [soorajvnair]()
[]: https://badge.fury.io/js/error-naturals.svg
[]: https://npmjs.org/package/error-naturals
[]: https://travis-ci.org/soorajvnair/error-naturals.svg?branch=master
[]: https://travis-ci.org/soorajvnair/error-naturals
[]: https://david-dm.org/soorajvnair/error-naturals.svg?theme=shields.io
[]: https://david-dm.org/soorajvnair/error-naturals