@appify/http-errors
v1.0.7
Published
Http error.
Downloads
10
Readme
@appify/http-errors
Exports http errors:
- HttpError
- BadRequest
- BadRequestHttpError
- Unauthorized
- UnauthorizedHttpError
- PaymentRequired
- PaymentRequiredHttpError
- Forbidden
- ForbiddenHttpError
- NotFound
- NotFoundHttpError
- MethodNotAllowed
- MethodNotAllowedHttpError
- NotAcceptable
- NotAcceptableHttpError
- ProxyAuthRequired
- ProxyAuthRequiredHttpError
- ClientTimeout
- ClientTimeoutHttpError
- Conflict
- ConflictHttpError
- Gone
- GoneHttpError
- PreconditionFailed
- PreconditionFailedHttpError
- UnsupportedMediaType
- UnsupportedMediaTypeHttpError
- ExpectationFailed
- ExpectationFailedHttpError
- UnprocessableEntity
- UnprocessableEntityHttpError
- Locked
- LockedHttpError
- PreconditionRequired
- PreconditionRequiredHttpError
- TooManyRequests
- TooManyRequestsHttpError
- InternalServerError
- InternalServerErrorHttpError
- NotImplemented
- NotImplementedHttpError
- BadGateway
- BadGatewayHttpError
- ServiceUnavailable
- ServiceUnavailableHttpError
- GatewayTimeout
- GatewayTimeoutHttpError
Instalation
npm install @appify/http-errors
BaseError
const { HttpError } = require('@appify/http-errors');
try {
throw new Error()
} catch (err) {
throw new HttpError(500, 'SERVER_ERROR', 'Something went wrong', err.stack)
}
Semantic error
const { InternalServerError } = require('@appify/http-errors');
try {
throw new TypeError()
} catch (err) {
throw new InternalServerError('Told ya that type was wrong', 'TYPE_ERROR')
}