@sleekify/sleekify
Version:
A TypeScript decorator driven approach for developing web applications.
329 lines (328 loc) • 13.1 kB
TypeScript
export interface ErrorOptions {
cause?: Error;
}
/**
* The base class for all HTTP errors.
*/
export declare class WebApplicationError extends Error {
private static reasonMap;
private readonly statusCode;
constructor(status: number, message?: string, options?: ErrorOptions);
get status(): number;
get reason(): string;
}
/**
* The base class for all HTTP 4XX errors which indicate the client's request
* is invalid and cause the error.
*/
export declare class ClientWebApplicationError extends WebApplicationError {
}
/**
* HTTP 400 - The server cannot or will not process the request due to an
* apparent client error (e.g., malformed request syntax, size too large,
* invalid request message framing, or deceptive request routing).
*/
export declare class BadRequestError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 401 - Similar to 403 Forbidden, but specifically for use when
* authentication is required and has failed or has not yet been provided. The
* response must include a WWW-Authenticate header field containing a challenge
* applicable to the requested resource.
*/
export declare class UnauthorizedError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 402 - Reserved for future use. The original intention was that this
* code might be used as part of some form of digital cash or micropayment
* scheme, as proposed, for example, but that has not yet happened, and this
* code is not widely used.
*/
export declare class PaymentRequiredError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 403 - The request contained valid data and was understood by the
* server, but the server is refusing action. This may be due to the user not
* having the necessary permissions for a resource or needing an account of
* some sort, or attempting a prohibited action.
*/
export declare class ForbiddenError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 404 - The requested resource could not be found but may be available in
* the future. Subsequent requests by the client are permissible.
*/
export declare class NotFoundError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 405 - A request method is not supported for the requested resource; for
* example, a GET request on a form that requires data to be presented via
* POST, or a PUT request on a read-only resource.
*/
export declare class MethodNotAllowedError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 406 - The requested resource is capable of generating only content not
* acceptable according to the Accept headers sent in the request.
*/
export declare class NotAcceptableError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 407 - The client must first authenticate itself with the proxy.
*/
export declare class ProxyAuthenticationRequiredError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 408 - The server timed out waiting for the request. According to HTTP
* specifications: "The client did not produce a request within the time that
* the server was prepared to wait. The client MAY repeat the request without
* modifications at any later time."
*/
export declare class RequestTimeoutError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 409 - Indicates that the request could not be processed because of
* conflict in the current state of the resource, such as an edit conflict
* between multiple simultaneous updates.
*/
export declare class ConflictError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 410 - Indicates that the resource requested was previously in use but
* is no longer available and will not be available again. This should be used
* when a resource has been intentionally removed and the resource should be
* purged.
*/
export declare class GoneError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 411 - The request did not specify the length of its content, which is
* required by the requested resource.
*/
export declare class LengthRequiredError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 412 - The server does not meet one of the preconditions that the
* requester put on the request header fields.
*/
export declare class PreconditionFailedError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 413 - The request is larger than the server is willing or able to
* process. Previously called "Request Entity Too Large".
*/
export declare class PayloadTooLargeError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 414 - The URI provided was too long for the server to process. Often
* the result of too much data being encoded as a query-string of a GET
* request, in which case it should be converted to a POST request.
*/
export declare class URITooLongError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 415 - The request entity has a media type which the server or resource
* does not support. For example, the client uploads an image as image/svg+xml,
* but the server requires that images use a different format.
*/
export declare class UnsupportedMediaTypeError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 416 - The client has asked for a portion of the file (byte serving),
* but the server cannot supply that portion.
*/
export declare class RangeNotSatisfiableError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 417 - The server cannot meet the requirements of the Expect
* request-header field.
*/
export declare class ExpectationFailedError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 418 - This code was defined in 1998 as one of the traditional IETF
* April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, and
* is not expected to be implemented by actual HTTP servers. The RFC specifies
* this code should be returned by teapots requested to brew coffee.
*/
export declare class IAmATeapotError extends ClientWebApplicationError {
private readonly reasonString;
constructor(message?: string, options?: ErrorOptions);
get reason(): string;
}
/**
* HTTP 421 - The request was directed at a server that is not able to produce
* a response (for example because of connection reuse).
*/
export declare class MisdirectedRequestError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 422 - The request was well-formed (i.e., syntactically correct) but
* could not be processed.
*/
export declare class UnprocessableContentError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 423 - The resource that is being accessed is locked.
*/
export declare class LockedError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 424 - The request failed because it depended on another request and
* that request failed
*/
export declare class FailedDependencyError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 425 - Indicates that the server is unwilling to risk processing a
* request that might be replayed.
*/
export declare class TooEarlyError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 426 - The client should switch to a different protocol such as TLS/1.3,
* given in the Upgrade header field.
*/
export declare class UpgradeRequiredError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 428 - The origin server requires the request to be conditional.
* Intended to prevent the 'lost update' problem, where a client GETs a
* resource's state, modifies it, and PUTs it back to the server, when
* meanwhile a third party has modified the state on the server, leading to a
* conflict.
*/
export declare class PreconditionRequiredError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 429 - The user has sent too many requests in a given amount of time.
* Intended for use with rate-limiting schemes.
*/
export declare class TooManyRequestsError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 431 - The server is unwilling to process the request because either an
* individual header field, or all the header fields collectively, are too
* large.
*/
export declare class RequestHeaderFieldsTooLargeError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 451 - A server operator has received a legal demand to deny access to a
* resource or to a set of resources that includes the requested resource.
*/
export declare class UnavailableForLegalReasonsError extends ClientWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* The base class for all HTTP 5XX errors which indicate the server encoutered
* a non-recoverable error.
*/
export declare class ServerWebApplicationError extends WebApplicationError {
}
/**
* HTTP 500 - A generic error message, given when an unexpected condition was
* encountered and no more specific message is suitable.
*/
export declare class InternalServerError extends ServerWebApplicationError {
private readonly reasonString;
constructor(message?: string, options?: ErrorOptions);
get reason(): string;
}
/**
* HTTP 501 - The server either does not recognize the request method, or it
* lacks the ability to fulfil the request. Usually this implies future
* availability (e.g., a new feature of a web-service API).
*/
export declare class NotImplementedError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 502 - The server was acting as a gateway or proxy and received an
* invalid response from the upstream server.
*/
export declare class BadGatewayError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 503 - The server cannot handle the request (because it is overloaded or
* down for maintenance). Generally, this is a temporary state.
*/
export declare class ServiceUnavailableError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 504 - The server was acting as a gateway or proxy and did not receive a
* timely response from the upstream server.
*/
export declare class GatewayTimeoutError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 505 - The server does not support the HTTP version used in the request.
*/
export declare class HTTPVersionNotSupportedError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 506 - Transparent content negotiation for the request results in a
* circular reference.
*/
export declare class VariantAlsoNegotiatesError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 507 - The server is unable to store the representation needed to
* complete the request.
*/
export declare class InsufficientStorageError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 508 - The server detected an infinite loop while processing the
* request.
*/
export declare class LoopDetectedError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 510 - Further extensions to the request are required for the server to
* fulfil it.
*/
export declare class NotExtendedError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}
/**
* HTTP 511 - The client needs to authenticate to gain network access. Intended
* for use by intercepting proxies used to control access to the network.
*/
export declare class NetworkAuthenticationRequiredError extends ServerWebApplicationError {
constructor(message?: string, options?: ErrorOptions);
}