Error mapper for Mali applications
npm install mali-error-mapperMali gRPC error mappers and middleware.
This middleware maps all non GrpcError errors to a GrpcError formatted accordingly.

Install the package via yarn:
``sh`
❯ yarn add mali-error-mapper
or via npm:
`sh`
❯ npm install mali-error-mapper --save
Using default mapping:
`javascript
'use strict';
const errorMapperMiddleware = require('mali-error-mapper');
const app = new Mali();
app.use(errorMapperMiddleware());
`
Using custom mappers:
`javascript
'use strict';
const errorMapperMiddleware = require('mali-error-mapper');
const app = new Mali();
const mapper = {
map: e => {
if (!(e instanceof MyError)) {
return;
}
return {
body: {
code: 'foo',
message: 'bar'
},
status: 999
};
};
};
app.use(errorMiddleware([mapper]));
``
MIT