1.0.2 • Published 1 year ago

http-errs v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

http-errs

HTTP errors ready to be thrown, possibly with a custom message.

Usage

Install:

yarn add http-errs

Use:

import { HTTP_ERROR, HTTP500 } from 'http-errs';

try {
  throw new HTTP500('What a mess!'); // if no message if provided, default one is used
}
catch (error) {
  if (error instanceof HTTP_ERROR) {
    console.error(error.message);
  }
  else {
    console.log('Another type of error not handled');
  }
}

Errors exported:

Status CodeMessage
400Bad Request
401Unauthorized
402PaymentRequired
403Forbidden
404NotFound
405MethodNotAllowed
406NotAcceptable
407ProxyAuthenticationRequired
408RequestTimeout
409Conflict
410Gone
411LengthRequired
412PreconditionFailed
413PayloadTooLarge
414URITooLong
415UnsupportedMediaType
416RangeNotSatisfiable
417ExpectationFailed
418ImATeapot
421MisdirectedRequest
422UnprocessableEntity
423Locked
424FailedDependency
425TooEarly
426UpgradeRequired
428PreconditionRequired
429TooManyRequests
431RequestHeaderFieldsTooLarge
451UnavailableForLegalReasons
500InternalServerError
501NotImplemented
502BadGateway
503ServiceUnavailable
504GatewayTimeout
505HTTPVersionNotSupported
506VariantAlsoNegotiates
507InsufficientStorage
508LoopDetected
509BandwidthLimitExceeded
510NotExtended
511NetworkAuthenticationRequired
1.0.2

1 year ago