mali-error-mapper

2.0.0 • Public • Published

Mali error mapper

Mali gRPC error mappers and middleware.

Middleware

This middleware maps all non GrpcError errors to a GrpcError formatted accordingly.

Status

Build Status

Installation

Install the package via yarn:

❯ yarn add mali-error-mapper

or via npm:

❯ npm install mali-error-mapper --save

Usage

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 (!(instanceof MyError)) {
      return;
    }
 
    return {
      body: {
        code: 'foo',
        message: 'bar'
      },
      status: 999
    };
  };
};
 
app.use(errorMiddleware([mapper]));

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i mali-error-mapper

Weekly Downloads

1,077

Version

2.0.0

License

MIT

Unpacked Size

215 kB

Total Files

11

Last publish

Collaborators

  • botatuphold
  • satazor
  • americas
  • kurayama
  • pedrobranco
  • fixe
  • franciscocardoso
  • cristiano.oliveira
  • ruimarinho
  • nunofgs