2.0.0 • Published 5 years ago
mali-error-mapper v2.0.0
Mali error mapper
Mali gRPC error mappers and middleware.
Middleware
This middleware maps all non GrpcError errors to a GrpcError formatted accordingly.
Status
Installation
Install the package via yarn:
❯ yarn add mali-error-mapperor via npm:
❯ npm install mali-error-mapper --saveUsage
Using default mapping:
'use strict';
const errorMapperMiddleware = require('mali-error-mapper');
const app = new Mali();
app.use(errorMapperMiddleware());Using custom mappers:
'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]));License
MIT