herrero
v1.1.0
Published
HTTP response status codes as errors
Downloads
6
Readme
4xx and 5xx response status codes error classes.
Usage
var BadRequestError = require('herrero').BadRequestError;
function doSomethingBad() {
throw new BadRequestError('It went bad!');
}
try {
doSomethingBad();
} catch (err) {
assert.strictEqual(err instanceof Error);
assert.strictEqual(err.name, 'BadRequestError');
assert.strictEqual(err.statusCode, 400);
}
Features
- Correct stack trace - no extra stack frames, no double capturing of the stack trace
Errors
[ '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',
'InternalServerErrorError',
'NotImplementedError',
'BadGatewayError',
'ServiceUnavailableError',
'GatewayTimeoutError',
'HTTPVersionNotSupportedError',
'VariantAlsoNegotiatesError',
'InsufficientStorageError',
'LoopDetectedError',
'BandwidthLimitExceededError',
'NotExtendedError',
'NetworkAuthenticationRequiredError' ]