This package has been deprecated

Author message:

WARNING: This package has been renamed. To install renamed package run 'npm i express-response-errors -S'

dw-http-errors

1.0.0-beta.7 • Public • Published

dw-http-errors NPM Version

Collection of custom response errors and middleware for express.

Install

npm i dw-http-errors -S

Configure

Add middleware to your application bootstrap file:

const { httpErrorsMiddleware } = require('dw-http-errors');
 
app.use(httpErrorsMiddleware);

Usage

Throw generic HTTP exception

const { HttpError } = require('dw-http-errors');
 
// Ex. with default status text
throw new HttpError(418);
 
// Ex. with custom message
throw new HttpError(418, 'I only brew tea');
 

Throw custom HTTP exception

const { ImATeapotError } = require('dw-http-errors');
 
// Ex. with default status text
throw new ImATeapotError();
 
// Ex. with custom status text
throw new ImATeapotError('I only brew tea');

Exceptions thrown without a message defaults to HTTP standard status text. Exceptions are handled by middle which relays errors as a HTTP response.

Base Exception

  • HttpError

Custom Exceptions

  • BadRequestError
  • UnauthorizedError
  • PaymentRequiredError
  • ForbiddenError
  • NotFoundError
  • MethodNotAllowedError
  • NotAcceptableError
  • ProxyAuthenticationRequiredError
  • RequestTimeoutError
  • ConflictError
  • GoneError
  • LengthRequiredError
  • PreconditionFailedError
  • PayloadTooLargeError
  • URITooLongError
  • UnsupportedMediaTypeError
  • RangeNotSatisfiableError
  • ExpectationFailedError
  • ImATeapotError
  • MisdirectedRequestError
  • UnprocessableEntityError
  • LockedError
  • FailedDependencyError
  • UnorderedCollectionError
  • UpgradeRequiredError
  • PreconditionRequiredError
  • TooManyRequestsError
  • RequestHeaderFieldsTooLargeError
  • UnavailableForLegalReasonsError
  • InternalServerError
  • NotImplementedError
  • BadGatewayError
  • ServiceUnavailableError
  • GatewayTimeoutError
  • HttpVersionNotSupportedError
  • VariantAlsoNegotiatesError
  • InsufficientStorageError
  • LoopDetectedError
  • BandwidthLimitExceededError
  • NotExtendedError
  • NetworkAuthenticationRequiredError

License

MIT

Package Sidebar

Install

npm i dw-http-errors

Weekly Downloads

3

Version

1.0.0-beta.7

License

MIT

Unpacked Size

12.1 kB

Total Files

10

Last publish

Collaborators

  • drodriques