Error Handler E2
This is handle error package
- Installation
- Usage
- Options
Installation
npm i error-handler-e2
yarn add error-handler-e2
Usage
const { Errors: { BadRequestError } } = require('error-handler-e2');
import { Errors } from 'error-handler-e2'
Options
- Errors
BadRequestError
const { Errors:{ BadRequestError }} = require('error-handler-e2');
throw new BadRequestError('Bad request error message', { time: new Date() });
ConflictError
const { Errors:{ ConflictError }} = require('error-handler-e2');
throw new ConflictError('conflict error message', { time: new Date() });
CustomError
const { Errors:{ CustomError }} = require('error-handler-e2');
throw new CustomError('Custom error message', { time: new Date() });
DatabaseError
const { Errors:{ DatabaseError }} = require('error-handler-e2');
throw new DatabaseError('Database error message', { time: new Date() });
InternalServerError
const { Errors:{ InternalServerError }} = require('error-handler-e2');
throw new InternalServerError('Internal Server error message', { time: new Date() });
NoContentError
const { Errors:{ NoContentError }} = require('error-handler-e2');
throw new NoContentError('NoContent error message', { time: new Date() });
NotFoundError
const { Errors:{ NotFoundError }} = require('error-handler-e2');
throw new NotFoundError('NotFound error message', { time: new Date() });
UnAuthenticatedError
const { Errors:{ UnAuthenticatedError }} = require('error-handler-e2');
throw new UnAuthenticatedError('UnAuthenticated error message', { time: new Date() });
UnAuthorizedError
const { Errors:{ UnAuthorizedError }} = require('error-handler-e2');
throw new UnAuthorizedError('UnAuthorized error message', { time: new Date() });
UnProcessableEntityError
const { Errors:{ UnProcessableEntityError }} = require('error-handler-e2');
throw new UnProcessableEntityError('UnProcessable Entity error message', { time: new Date() });
- Http Status
NO_CONTENT 204
const { StatusCodes: { NO_CONTENT } } = require('error-handler-e2');
BAD_REQUEST 400
const { StatusCodes: { BAD_REQUEST } } = require('error-handler-e2');
UNAUTHENTICATED 401
const { StatusCodes: { UNAUTHENTICATED } } = require('error-handler-e2');
UNAUTHORIZED 403
const { StatusCodes: { UNAUTHORIZED } } = require('error-handler-e2');
NOT_FOUND 404
const { StatusCodes: { NOT_FOUND } } = require('error-handler-e2');
CONFLICT 409
const { StatusCodes: { CONFLICT } } = require('error-handler-e2');
UNPROCURABLE_ENTITY 422
const { StatusCodes: { UNPROCURABLE_ENTITY } } = require('error-handler-e2');
INTERNAL_SERVER_ERROR 500
const { StatusCodes: { INTERNAL_SERVER_ERROR } } = require('error-handler-e2');
- Middleware
loggerMiddleware
const { Middleware:{ loggerMiddleware }} = require('error-handler-e2');
app.use(loggerMiddleware);