UNPKG

@selfage/http_error

Version:
96 lines (95 loc) 5.43 kB
import { NestedError } from "@selfage/nested_error"; export declare enum StatusCode { BadRequest = 400, Unauthorized = 401, PaymentRequired = 402, Forbidden = 403, NotFound = 404, MethodNotAllowed = 405, NotAcceptable = 406, ProxyAuthenticationRequired = 407, RequestTimeout = 408, Conflict = 409, Gone = 410, LengthRequired = 411, PreconditionFailed = 412, PayloadTooLarge = 413, URITooLong = 414, UnsupportedMediaType = 415, RangeNotSatisfiable = 416, ExpectationFailed = 417, ImATeapot = 418, MisdirectedRequest = 421, UnprocessableEntity = 422, Locked = 423, FailedDependency = 424, UnorderedCollection = 425, UpgradeRequired = 426, PreconditionRequired = 428, TooManyRequests = 429, RequestHeaderFieldsTooLarge = 431, UnavailableForLegalReasons = 451, InternalServerError = 500, NotImplemented = 501, BadGateway = 502, ServiceUnavailable = 503, GatewayTimeout = 504, HTTPVersionNotSupported = 505, VariantAlsoNegotiates = 506, InsufficientStorage = 507, LoopDetected = 508, BandwidthLimitExceeded = 509, NotExtended = 510, NetworkAuthenticationRequired = 511 } export declare class HttpError extends NestedError { statusCode: number; cause?: any; status: number; constructor(statusCode: number, message: string, cause?: any); } export declare function isClientError(httpError: HttpError): boolean; export declare function isClientErrorCode(code: StatusCode): boolean; export declare function isServerError(httpError: HttpError): boolean; export declare function isServerErrorCode(code: StatusCode): boolean; export declare function newBadRequestError(message: string, cause?: any): HttpError; export declare function newUnauthorizedError(message: string, cause?: any): HttpError; export declare function newPaymentRequiredError(message: string, cause?: any): HttpError; export declare function newForbiddenError(message: string, cause?: any): HttpError; export declare function newNotFoundError(message: string, cause?: any): HttpError; export declare function newMethodNotAllowedError(message: string, cause?: any): HttpError; export declare function newNotAcceptableError(message: string, cause?: any): HttpError; export declare function newProxyAuthenticationRequiredError(message: string, cause?: any): HttpError; export declare function newRequestTimeoutRequiredError(message: string, cause?: any): HttpError; export declare function newConflictError(message: string, cause?: any): HttpError; export declare function newGoneError(message: string, cause?: any): HttpError; export declare function newLengthRequiredError(message: string, cause?: any): HttpError; export declare function newPreconditionFailedError(message: string, cause?: any): HttpError; export declare function newPayloadTooLargeError(message: string, cause?: any): HttpError; export declare function newURITooLongError(message: string, cause?: any): HttpError; export declare function newUnsupportedMediaTypeError(message: string, cause?: any): HttpError; export declare function newRangeNotSatisfiableError(message: string, cause?: any): HttpError; export declare function newExpectationFailedError(message: string, cause?: any): HttpError; export declare function newImATeapotError(message: string, cause?: any): HttpError; export declare function newMisdirectedRequestError(message: string, cause?: any): HttpError; export declare function newUnprocessableEntityError(message: string, cause?: any): HttpError; export declare function newLockedError(message: string, cause?: any): HttpError; export declare function newFailedDependencyError(message: string, cause?: any): HttpError; export declare function newUnorderedCollectionError(message: string, cause?: any): HttpError; export declare function newUpgradeRequiredError(message: string, cause?: any): HttpError; export declare function newPreconditionRequiredError(message: string, cause?: any): HttpError; export declare function newTooManyRequestsError(message: string, cause?: any): HttpError; export declare function newRequestHeaderFieldsTooLargeError(message: string, cause?: any): HttpError; export declare function newUnavailableForLegalReasonsError(message: string, cause?: any): HttpError; export declare function newInternalServerErrorError(message: string, cause?: any): HttpError; export declare function newNotImplementedError(message: string, cause?: any): HttpError; export declare function newBadGatewayError(message: string, cause?: any): HttpError; export declare function newServiceUnavailableError(message: string, cause?: any): HttpError; export declare function newGatewayTimeoutError(message: string, cause?: any): HttpError; export declare function newHTTPVersionNotSupportedError(message: string, cause?: any): HttpError; export declare function newVariantAlsoNegotiatesError(message: string, cause?: any): HttpError; export declare function newInsufficientStorageError(message: string, cause?: any): HttpError; export declare function newLoopDetectedError(message: string, cause?: any): HttpError; export declare function newBandwidthLimitExceededError(message: string, cause?: any): HttpError; export declare function newNotExtendedError(message: string, cause?: any): HttpError; export declare function newNetworkAuthenticationRequiredError(message: string, cause?: any): HttpError;