@c8/errors
Advanced tools
Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "@c8/errors", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Common errors and their utils used by C8 management", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# @c8/errors | ||
Common error type in our components | ||
Common error types and utils for use in our components | ||
## Usage | ||
- `npm i --save @c8/errors` | ||
```javascript | ||
'use strict' | ||
- ```javascript | ||
const Errors = require('@c8/errors') | ||
``` | ||
// You will typically be fine just keeping the default mapping | ||
### Throw a custom Error with parameters | ||
```javascript | ||
throw new Errors.TypeError('Error message', { | ||
myParam1: 'Foo', | ||
myParam2: 'Bar' | ||
}) | ||
``` | ||
### Translate your error to Boom error | ||
#### With defaut mapping | ||
```javascript | ||
let boomErr = Errors.utils.toBoom(err) | ||
``` | ||
// But you can also specify the second parameter of toBoom() if I don't like the default mapping | ||
#### With custom mapping | ||
```javascript | ||
let boomErr = Errors.utils.toBoom(err, { | ||
@@ -15,0 +29,0 @@ entityTooLarge: ['FileTooLargeError'], |
4721
34