@roarr/middleware-serialize-error
Version:
Serializes error objects in the Roarr message context.
31 lines (19 loc) • 1.21 kB
Markdown
# @roarr/middleware-serialize-error
[](https://travis-ci.org/gajus/roarr)
[](https://coveralls.io/github/gajus/roarr)
[](https://www.npmjs.org/package/roarr)
[](https://github.com/gajus/canonical)
[](https://twitter.com/kuizinas)
Serializes error objects in the [Roarr](https://github.com/gajus/roarr) message context.
## Behaviour
The current implementation maps only the direct context properties.
Raise an issue if you have a use case that requires deep property mapping.
## Usage
```js
import log from 'roarr';
import createSerializeErrorMiddleware from '@roarr/middleware-serialize-error';
const childLog = log.child(createSerializeErrorMiddleware());
const error = new Error('foo');
log.debug({error}, 'bar');
childLog.debug({error}, 'bar');
```