@panthera-errors/custom-errors
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

README

This is the list of custom errors of panthera platform

What is this repository for?

  • This repo was created for handling custom errors for the platform

How do I get set up?

  • npm i @panthera-errors/custom-errors

  • Bad Request Error import { BadRequestError } from '@panthera-errors/custom-errors' throw new BadRequestError('your message'); response type:

    status: 400
        {
            errors: 
                [
                    {
                        message: your message;
                    }
                ]
        }
  • Database Connection Error import { DatabaseConnectionError } from '@panthera-errors/custom-errors' throw new DatabaseConnectionError(); response type:
    status: 500
        {
            errors: 
                [
                    {
                        message: Error connecting to database;
                    }
                ]
        }
  • Database Connection Error import { DatabaseConnectionError } from '@panthera-errors/custom-errors' throw new DatabaseConnectionError(); response type:
    status: 500
        {
            errors: 
                [
                    {
                        message: Error connecting to database;
                    }
                ]
        }
  • Not Authorized Error import { NotAuthorizedError } from '@panthera-errors/custom-errors' throw new NotAuthorizedError(); response type:
    status: 401
        {
            errors: 
                [
                    {
                        message: Not authorized;
                    }
                ]
        }
  • Not Found Error import { NotFoundError } from '@panthera-errors/custom-errors' throw new NotFoundError(); response type:
    status: 404
        {
            errors: 
                [
                    {
                        message: Not Found;
                    }
                ]
        }
  • Request Validation Error import { RequestValidationError } from '@panthera-errors/custom-errors' throw new RequestValidationError(); response type:
    status: 400
        {
            errors: 
                [
                    {
                        message: error message,
                        field: error param
                    },
                    {
                        message: error message,
                        field: error param
                    }
                ]
        }
  • Request Validation Error import { errorHandler } from '@panthera-errors/custom-errors' app.use(errorHandler); response type:
    status: 400
        {
            errors: 
                [
                   {
                       message: 'Something went wrong'
                   }
                ]
        }
  • Request Validation middleware - uses express-validator import { validateRequest } from '@panthera-errors/custom-errors'

response type:

    status: 400
        {
            errors: 
                [
                   {
                       message: 'Invalid request parameters'
                   }
                ]
        }

/@panthera-errors/custom-errors/

    Package Sidebar

    Install

    npm i @panthera-errors/custom-errors

    Weekly Downloads

    32

    Version

    1.4.0

    License

    ISC

    Unpacked Size

    17.9 kB

    Total Files

    22

    Last publish

    Collaborators

    • nikita_airhead