1.0.0-beta.7 • Published 6 years ago
dw-http-errors v1.0.0-beta.7
dw-http-errors
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
1.0.0-beta.7
6 years ago
1.0.0-beta.6
6 years ago
1.0.0-beta.5
6 years ago
1.0.0-beta.4
6 years ago
1.0.0-beta.3
6 years ago
1.0.0-beta.2
6 years ago
1.0.0-beta.1
6 years ago
1.0.0-beta.0
6 years ago