1.0.0 • Published 4 years ago

http-errors-response-ts v1.0.0

Weekly downloads
8
License
ISC
Repository
github
Last release
4 years ago

HTTP errors response

This library provide some Error classes to map the problems that you may want to report to your clients.

Usage

npm install http-errors-response-ts --save

Usage

import error from lib
import { BadRequestResponse } from 'http-errors-response-ts';

throw new BadRequestResponse();

expexted object

{
  "statusCode": 400,
  "message": "Bad Request"
}
with custom message
import { BadRequestResponse } from 'http-errors-response-ts';

throw new BadRequestResponse('Custom message');

expexted object

{
  "statusCode": 400,
  "message": "Custom message"
}

List of all Error

Status CodeError Name
400BadRequestResponse
401UnauthorizedResponse
402PaymentRequiredResponse
403ForbiddenResponse
404NotFoundResponse
405MethodNotAllowedResponse
406NotAcceptableResponse
407ProxyAuthenticationRequiredResponse
408RequestTimeoutResponse
409ConflictResponse
410GoneResponse
411LengthRequiredResponse
412PreconditionFailedResponse
413PayloadTooLargeResponse
414URITooLongResponse
415UnsupportedMediaTypeResponse
416RangeNotSatisfiableResponse
417ExpectationFailedResponse
418ImATeapotResponse
421MisdirectedRequestResponse
422UnprocessableEntityResponse
423LockedResponse
424FailedDependencyResponse
425UnorderedCollectionResponse
426UpgradeRequiredResponse
428PreconditionRequiredResponse
429TooManyRequestsResponse
431RequestHeaderFieldsTooLargeResponse
451UnavailableForLegalReasonsResponse
500InternalServerErrorResponse
501NotImplementedResponse
502BadGatewayResponse
503ServiceUnavailableResponse
504GatewayTimeoutResponse
505HTTPVersionNotSupportedResponse
506VariantAlsoNegotiatesResponse
507InsufficientStorageResponse
508LoopDetectedResponse
509BandwidthLimitExceededResponse
510NotExtendedResponse
511NetworkAuthenticationRequiredResponse