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'
}
]
}