declare class HttpBadRequest extends HttpClientException { static readonly STATUS = 400; constructor(msgOrParams?: HttpExceptionParams | string); } type HttpMethod = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'QUERY' | 'TRACE'; type HttpExceptionParams = { /** * Indicates the original cause of the HttpException. * Will be ignored/discarded if the runtime (browser / node version) does not support it * or there's no polyfill * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause */ cause?: Error | HttpException | undefined; /** * Custom additional code (ie: 'ERR_UNREACHABLE_SERVICE', 'AbortError', 'cdg1::h99k2-1664884491087-b41a2832f559'...) * Do not use this to indicate http status code, the `statusCode` is built-in. */ code?: string | undefined; /** * Inform about an unique error identifier (ie: nanoid, cuid, sentry...) */ errorId?: string | undefined; /** * Exception message, if not provided the default is the exception * name in natural language (ie: "HttpNotFound" -> "Not found") */ message?: string | undefined; /** * Inform about http method */ method?: HttpMethod | undefined; /** * Indicates the original url that caused the error. */ url?: string | undefined; }; declare class HttpConflict extends HttpClientException { static readonly STATUS = 409; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpExpectationFailed extends HttpClientException { static readonly STATUS = 417; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpFailedDependency extends HttpClientException { static readonly STATUS = 424; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpForbidden extends HttpClientException { static readonly STATUS = 403; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpGone extends HttpClientException { static readonly STATUS = 410; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpImATeapot extends HttpClientException { static readonly STATUS = 418; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpLengthRequired extends HttpClientException { static readonly STATUS = 411; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpLocked extends HttpClientException { static readonly STATUS = 423; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpMethodNotAllowed extends HttpClientException { static readonly STATUS = 405; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpMisdirectedRequest extends HttpClientException { static readonly STATUS = 421; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpNotAcceptable extends HttpClientException { static readonly STATUS = 406; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpNotFound extends HttpClientException { static readonly STATUS = 404; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpPayloadTooLarge extends HttpClientException { static readonly STATUS = 413; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpPaymentRequired extends HttpClientException { static readonly STATUS = 402; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpPreconditionFailed extends HttpClientException { static readonly STATUS = 412; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpPreconditionRequired extends HttpClientException { static readonly STATUS = 428; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpProxyAuthenticationRequired extends HttpClientException { static readonly STATUS = 407; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpRangeNotSatisfiable extends HttpClientException { static readonly STATUS = 416; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpRequestHeaderFieldsTooLarge extends HttpClientException { static readonly STATUS = 431; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpRequestTimeout extends HttpClientException { static readonly STATUS = 408; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpTooEarly extends HttpClientException { static readonly STATUS = 425; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpTooManyRequests extends HttpClientException { static readonly STATUS = 429; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpUnauthorized extends HttpClientException { static readonly STATUS = 401; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpUnavailableForLegalReasons extends HttpClientException { static readonly STATUS = 451; constructor(msgOrParams?: HttpExceptionParams | string); } /** * Related to HttpBadRequest, HttpValidationIssue contains additional validation info. * Slightly inspired from https://jsonapi.org/format/1.2/#error-objects * and zod (path). */ type HttpValidationIssue = { /** An application-specific error code, expressed as a string value. */ code?: string; /** A short, human-readable summary of the problem */ message: string; /** Param name or path, ie: 'email' or ['addresses', 0, 'line1'] */ path: (number | string)[] | string; }; /** * Special case for 422 UnprocessableEntity */ type HttpExceptionParamsWithIssues = HttpExceptionParams & { issues?: HttpValidationIssue[]; }; declare class HttpUnprocessableEntity extends HttpClientException { static readonly STATUS = 422; readonly issues: HttpValidationIssue[]; constructor(msgOrParams?: HttpExceptionParamsWithIssues | string); } declare class HttpUnsupportedMediaType extends HttpClientException { static readonly STATUS = 415; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpUpgradeRequired extends HttpClientException { static readonly STATUS = 426; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpUriTooLong extends HttpClientException { static readonly STATUS = 414; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpException extends Error implements HttpExceptionParams { /** * If set and the runtime (browser or node) supports it * you can get back the error cause * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause */ readonly cause?: Error | HttpException | undefined; /** * Custom additional code (ie: 'ERR_UNREACHABLE_SERVICE', 'AbortError', 'cdg1::h99k2-1664884491087-b41a2832f559'...) */ readonly code: string | undefined; /** * Inform about an unique error identifier (ie: nanoid, cuid...) */ readonly errorId: string | undefined; /** * Http method */ readonly method: HttpMethod | undefined; /** * Http error status code (400-599) */ readonly statusCode: HttpErrorStatusCodeOrNumber; /** * Indicates the original url that caused the error. */ readonly url: string | undefined; /** * Construct a new HttpException class * * @param statusCode http status code between 400-599, no checks are done on the validity of the number. * @param msgOrParams either a message or an object containing HttpExceptionParams */ constructor(statusCode: HttpErrorStatusCodeOrNumber, msgOrParams?: HttpExceptionParams | string); } /** * Construct a new HttpServerException class * * @param statusCode http status code between 500-599, no checks are done on the validity of the number. * @param msgOrParams either a message or an object containing HttpExceptionParams */ declare class HttpServerException extends HttpException { constructor(statusCode: HttpErrorStatusCodeOrNumber, msgOrParams?: HttpExceptionParams | string); } declare class HttpBadGateway extends HttpServerException { static readonly STATUS = 502; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpGatewayTimeout extends HttpServerException { static readonly STATUS = 504; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpInsufficientStorage extends HttpServerException { static readonly STATUS = 507; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpInternalServerError extends HttpServerException { static readonly STATUS = 500; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpLoopDetected extends HttpServerException { static readonly STATUS = 508; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpNetworkAuthenticationRequired extends HttpServerException { static readonly STATUS = 511; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpNotExtended extends HttpServerException { static readonly STATUS = 510; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpNotImplemented extends HttpServerException { static readonly STATUS = 501; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpServiceUnavailable extends HttpServerException { static readonly STATUS = 503; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpVariantAlsoNegotiates extends HttpServerException { static readonly STATUS = 506; constructor(msgOrParams?: HttpExceptionParams | string); } declare class HttpVersionNotSupported extends HttpServerException { static readonly STATUS = 505; constructor(msgOrParams?: HttpExceptionParams | string); } declare const statusMap: { 400: typeof HttpBadRequest; 401: typeof HttpUnauthorized; 402: typeof HttpPaymentRequired; 403: typeof HttpForbidden; 404: typeof HttpNotFound; 405: typeof HttpMethodNotAllowed; 406: typeof HttpNotAcceptable; 407: typeof HttpProxyAuthenticationRequired; 408: typeof HttpRequestTimeout; 409: typeof HttpConflict; 410: typeof HttpGone; 411: typeof HttpLengthRequired; 412: typeof HttpPreconditionFailed; 413: typeof HttpPayloadTooLarge; 414: typeof HttpUriTooLong; 415: typeof HttpUnsupportedMediaType; 416: typeof HttpRangeNotSatisfiable; 417: typeof HttpExpectationFailed; 418: typeof HttpImATeapot; 421: typeof HttpMisdirectedRequest; 422: typeof HttpUnprocessableEntity; 423: typeof HttpLocked; 424: typeof HttpFailedDependency; 425: typeof HttpTooEarly; 426: typeof HttpUpgradeRequired; 428: typeof HttpPreconditionRequired; 429: typeof HttpTooManyRequests; 431: typeof HttpRequestHeaderFieldsTooLarge; 451: typeof HttpUnavailableForLegalReasons; 500: typeof HttpInternalServerError; 501: typeof HttpNotImplemented; 502: typeof HttpBadGateway; 503: typeof HttpServiceUnavailable; 504: typeof HttpGatewayTimeout; 505: typeof HttpVersionNotSupported; 506: typeof HttpVariantAlsoNegotiates; 507: typeof HttpInsufficientStorage; 508: typeof HttpLoopDetected; 510: typeof HttpNotExtended; 511: typeof HttpNetworkAuthenticationRequired; }; type HttpErrorStatusCode = keyof typeof statusMap; type HttpErrorStatusCodeOrNumber = HttpErrorStatusCode | (number & {}); /** * Construct a new HttpClientException class * * @param statusCode http status code between 400-499, no checks are done on the validity of the number. * @param msgOrParams either a message or an object containing HttpExceptionParams */ declare class HttpClientException extends HttpException { constructor(statusCode: HttpErrorStatusCodeOrNumber, msgOrParams?: HttpExceptionParams | string); } export { HttpNotFound as A, HttpNotImplemented as B, HttpPayloadTooLarge as C, HttpPaymentRequired as D, HttpPreconditionFailed as E, HttpPreconditionRequired as F, HttpProxyAuthenticationRequired as G, type HttpErrorStatusCodeOrNumber as H, HttpRangeNotSatisfiable as I, HttpRequestHeaderFieldsTooLarge as J, HttpRequestTimeout as K, HttpServiceUnavailable as L, HttpTooEarly as M, HttpTooManyRequests as N, HttpUnauthorized as O, HttpUnavailableForLegalReasons as P, HttpUnsupportedMediaType as Q, HttpUpgradeRequired as R, HttpUriTooLong as S, type HttpValidationIssue as T, HttpVariantAlsoNegotiates as U, HttpVersionNotSupported as V, type HttpMethod as W, type HttpExceptionParams as a, type HttpErrorStatusCode as b, type HttpExceptionParamsWithIssues as c, HttpUnprocessableEntity as d, HttpClientException as e, HttpException as f, HttpServerException as g, HttpBadGateway as h, HttpBadRequest as i, HttpConflict as j, HttpExpectationFailed as k, HttpFailedDependency as l, HttpForbidden as m, HttpGatewayTimeout as n, HttpGone as o, HttpImATeapot as p, HttpInsufficientStorage as q, HttpInternalServerError as r, HttpLengthRequired as s, HttpLocked as t, HttpLoopDetected as u, HttpMethodNotAllowed as v, HttpMisdirectedRequest as w, HttpNetworkAuthenticationRequired as x, HttpNotAcceptable as y, HttpNotExtended as z };