@dotcom-gosahi/centralized-exception-and-error-handling

1.0.1 • Public • Published

What is this?

It a library for providing centralized error and exception handling with mongo DB. It is mainly used by Indian Aces Organization in their different projects.

Installation

npm i @dotcom-gosahi/centralized-exception-and-error-handling

Then...

const errorHandler = require('@dotcom-gosahi/centralized-exception-and-error-handling');

app.use(errorHandler(
  {
    environment: ENV,
    configuration: {
      connection: db,
      errorDbName: error_db_Name
    }
  }));

Then...

const { APIError, httpErrorCodes} = require('@dotcom-gosahi/centralized-exception-and-error-handling');

res.status(httpErrorCodes.CREATED).json({ message: 'Inserted Successfully!' });

next(APIError.BadRequest(err.message));

Options

httpErrorCodes has following error codes: * OK * CREATED * BAD_REQUEST * UNAUTHORIZED * NOT_FOUND * INTERNAL_SERVER * UPDATED

Environments - LOCAL / TEST / DEV / PROD

APIError has following methods: * BadRequest * UnathorisedRequest * NotFoundRequest * ServerError

Package Sidebar

Install

npm i @dotcom-gosahi/centralized-exception-and-error-handling

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

7.31 kB

Total Files

7

Last publish

Collaborators

  • dotcom-gosahi1