1.0.0 • Published 3 years ago
@ct-ibd/error-handler v1.0.0
Error handler
Package for handling http errors.
Installation
npm install @ct-ibd/error-handler --registry https://eu.artifactory.conti.de/artifactory/api/npm/ct_ibd_digital_npm_l/
Following http error classes are included
4XX
- ErrBadRequest
- ErrForbidden
- ErrNotFound
- ErrMethodNotAllowed
- ErrNotAcceptable
- ErrRequestTimeout
- ErrProxyAuthenticationRequired
- ErrConflict
- ErrGone
- ErrLengthRequired
- ErrPreconditionFailed
- ErrPayloadTooLarge
- ErrUriTooLong
- ErrUnsupportedMediaType
- ErrRangeNotSatisfiable
- ErrExpectationFailed
- ErrIamATeapot
- ErrMisdirectedRequest
- ErrUnprocessableEntiry
- ErrLocked
- ErrFailedDependency
- ErrTooEarly
- ErrUpgradeRequired
- ErrPreconditionRequired
- ErrTooManyRequests
- ErrRequestHeaderTooLarg
- ErrUnAvailableForLegalReasons
5XX
- ErrInternalServerError
- ErrNotImplemented
- ErrBadGateway
- ErrServiceUnavailable
- ErrGatewayTimeout
- ErrHttpVersionNotSupported
- ErrVariantAlsoNegotiates
- ErrInsufficientStorage
- ErrLoopDetected
- ErrNotExtended
- ErrNetworkAuthenticationRequired
- ErrCustom
Example usage
const err = new ErrBadRequest('Invalid paramaeter specified');
// variable err will be containing following object
{ statusCode: 400, message: 'Bad Request: Invalid paramaeter specified'}
1.0.0
3 years ago