http-error-kit
Version:
A flexible and customizable error-handling library for HTTP applications. Provides structured error responses with optional formatters, predefined HTTP errors, and extensible error types.
554 lines (553 loc) • 23.1 kB
TypeScript
import { IRawInput } from "./interfaces/input.interface";
/**
* Represents a general error with a status code, message, and optional details.
* @extends {Error}
*/
export declare class KitGeneralError extends Error {
/**
* The HTTP status code associated with the error.
* @type {number}
*/
statusCode: number;
/**
* A human-readable error message.
* @type {string}
*/
message: string;
/**
* Additional details about the error, if any.
* @type {*}
*/
details: unknown;
/**
* The raw input data associated with this instance.
* @private
* @type {IRawInput}
*/
private rawInputs;
/**
* Initializes a new instance of the KitGeneralError class.
* @param {number} statusCode - The HTTP status code associated with the error.
* @param {string} message - A human-readable error message.
* @param {*} details - Additional details about the error, if any.
*/
constructor(statusCode: number, message: string, details?: unknown);
/**
* Returns the raw input data associated with this instance.
* @returns {IRawInput} The raw input data associated with this instance.
*/
getInputs(): IRawInput;
/**
* Returns a JSON-compatible object representation of this instance.
* @returns {{statusCode: number, message: string, details: unknown}} A JSON-compatible object representation of this instance.
*/
toJSON(): {
statusCode: number;
message: string;
details: unknown;
};
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 400, Bad Request.
* @extends KitGeneralError
*/
export declare class BadRequestError extends KitGeneralError {
/**
* Initializes a new instance of the BadRequestError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 400.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 401, Unauthorized.
* @extends KitGeneralError
*/
export declare class UnauthorizedError extends KitGeneralError {
/**
* Initializes a new instance of the UnauthorizedError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 401.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 402, Payment Required.
* @extends KitGeneralError
*/
export declare class PaymentRequiredError extends KitGeneralError {
/**
* Initializes a new instance of the PaymentRequiredError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 402.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 403, Forbidden.
* @extends KitGeneralError
*/
export declare class ForbiddenError extends KitGeneralError {
/**
* Initializes a new instance of the ForbiddenError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 403.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 404, Not Found.
* @extends KitGeneralError
*/
export declare class NotFoundError extends KitGeneralError {
/**
* Initializes a new instance of the NotFoundError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 404.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 405, Method Not Allowed.
* @extends KitGeneralError
*/
export declare class MethodNotAllowedError extends KitGeneralError {
/**
* Initializes a new instance of the MethodNotAllowedError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 405.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 406, Not Acceptable.
* @extends KitGeneralError
*/
export declare class NotAcceptableError extends KitGeneralError {
/**
* Initializes a new instance of the NotAcceptableError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 406.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 407, Proxy Authentication Required.
* @extends KitGeneralError
*/
export declare class ProxyAuthenticationRequiredError extends KitGeneralError {
/**
* Initializes a new instance of the ProxyAuthenticationRequiredError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 407.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 408, Request Timeout.
* @extends KitGeneralError
*/
export declare class RequestTimeoutError extends KitGeneralError {
/**
* Initializes a new instance of the RequestTimeoutError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 408.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 409, Conflict.
* @extends KitGeneralError
*/
export declare class ConflictError extends KitGeneralError {
/**
* Initializes a new instance of the ConflictError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 409.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 410, Gone.
* @extends KitGeneralError
*/
export declare class GoneError extends KitGeneralError {
/**
* Initializes a new instance of the GoneError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 410.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 411, Length Required.
* @extends KitGeneralError
*/
export declare class LengthRequiredError extends KitGeneralError {
/**
* Initializes a new instance of the LengthRequiredError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 411.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 412, Precondition Failed.
* @extends KitGeneralError
*/
export declare class PreconditionFailedError extends KitGeneralError {
/**
* Initializes a new instance of the PreconditionFailedError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 412.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 413, Request Entity Too Large.
* @extends KitGeneralError
*/
export declare class RequestTooLongError extends KitGeneralError {
/**
* Initializes a new instance of the RequestTooLongError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 413.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 414, Request-URI Too Long.
* @extends KitGeneralError
*/
export declare class RequestUriTooLongError extends KitGeneralError {
/**
* Initializes a new instance of the RequestUriTooLongError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 414.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 415, Unsupported Media Type.
* @extends KitGeneralError
*/
export declare class UnsupportedMediaTypeError extends KitGeneralError {
/**
* Initializes a new instance of the UnsupportedMediaTypeError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 415.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 416, Requested Range Not Satisfiable.
* @extends KitGeneralError
*/
export declare class RequestedRangeNotSatisfiableError extends KitGeneralError {
/**
* Initializes a new instance of the RequestedRangeNotSatisfiableError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 416.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 417, Expectation Failed.
* @extends KitGeneralError
*/
export declare class ExpectationFailedError extends KitGeneralError {
/**
* Initializes a new instance of the ExpectationFailedError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 417.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 418, I'm a teapot.
* @extends KitGeneralError
*/
export declare class ImATeapotError extends KitGeneralError {
/**
* Initializes a new instance of the ImATeapotError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 418.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 419, Insufficient Space on Resource.
* @extends KitGeneralError
*/
export declare class InsufficientSpaceOnResourceError extends KitGeneralError {
/**
* Initializes a new instance of the InsufficientSpaceOnResourceError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 419.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 420, Method Failure.
* @extends KitGeneralError
*/
export declare class MethodFailureError extends KitGeneralError {
/**
* Initializes a new instance of the MethodFailureError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 420.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 421, Misdirected Request.
* @extends KitGeneralError
*/
export declare class MisdirectedRequestError extends KitGeneralError {
/**
* Initializes a new instance of the MisdirectedRequestError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 421.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 422, Unprocessable Entity.
* @extends KitGeneralError
*/
export declare class UnprocessableEntityError extends KitGeneralError {
/**
* Initializes a new instance of the UnprocessableEntityError class.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 422.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 423, Locked.
* @extends KitGeneralError
*/
export declare class LockedError extends KitGeneralError {
/**
* Initializes a new LockedError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 423.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 424, Failed Dependency.
* @extends {KitGeneralError}
*/
export declare class FailedDependencyError extends KitGeneralError {
/**
* Initializes a new FailedDependencyError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 424.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 425, Too Early.
* @extends {KitGeneralError}
*/
export declare class TooEarlyError extends KitGeneralError {
/**
* Initializes a new TooEarlyError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 425.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 426, Upgrade Required.
* @extends {KitGeneralError}
*/
export declare class UpgradeRequiredError extends KitGeneralError {
/**
* Initializes a new UpgradeRequiredError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 426.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 428, Precondition Required.
* @extends {KitGeneralError}
*/
export declare class PreconditionRequiredError extends KitGeneralError {
/**
* Initializes a new PreconditionRequiredError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 428.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 429, Too Many Requests.
* @extends {KitGeneralError}
*/
export declare class TooManyRequestsError extends KitGeneralError {
/**
* Initializes a new TooManyRequestsError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 429.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 431, Request Header Fields Too Large.
* @extends {KitGeneralError}
*/
export declare class RequestHeaderFieldsTooLargeError extends KitGeneralError {
/**
* Initializes a new RequestHeaderFieldsTooLargeError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 431.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 451, Unavailable For Legal Reasons.
* @extends {KitGeneralError}
*/
export declare class UnavailableForLegalReasonsError extends KitGeneralError {
/**
* Initializes a new UnavailableForLegalReasonsError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 451.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 500, Internal Server Error.
* @extends {KitGeneralError}
*/
export declare class InternalServerError extends KitGeneralError {
/**
* Initializes a new InternalServerErrorError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 500.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 501, Not Implemented.
* @extends {KitGeneralError}
*/
export declare class NotImplementedError extends KitGeneralError {
/**
* Initializes a new NotImplementedError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 501.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 502, Bad Gateway.
* @extends {KitGeneralError}
*/
export declare class BadGatewayError extends KitGeneralError {
/**
* Initializes a new BadGatewayError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 502.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 503, Service Unavailable.
* @extends {KitGeneralError}
*/
export declare class ServiceUnavailableError extends KitGeneralError {
/**
* Initializes a new ServiceUnavailableError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 503.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 504, Gateway Timeout.
* @extends {KitGeneralError}
*/
export declare class GatewayTimeoutError extends KitGeneralError {
/**
* Initializes a new GatewayTimeoutError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 504.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 505, HTTP Version Not Supported.
* @extends {KitGeneralError}
*/
export declare class HttpVersionNotSupportedError extends KitGeneralError {
/**
* Initializes a new HttpVersionNotSupportedError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 505.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 506, Variant Also Negotiates.
* @extends {KitGeneralError}
*/
export declare class VariantAlsoNegotiatesError extends KitGeneralError {
/**
* Initializes a new VariantAlsoNegotiatesError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 506.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 507, Insufficient Storage.
* @extends {KitGeneralError}
*/
export declare class InsufficientStorageError extends KitGeneralError {
/**
* Initializes a new InsufficientStorageError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 507.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 508, Loop Detected.
* @extends {KitGeneralError}
*/
export declare class LoopDetectedError extends KitGeneralError {
/**
* Initializes a new LoopDetectedError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 508.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 510, Not Extended.
* @extends {KitGeneralError}
*/
export declare class NotExtendedError extends KitGeneralError {
/**
* Initializes a new NotExtendedError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 510.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}
/**
* Creates a new instance of the KitGeneralError class with a status code of 511, Network Authentication Required.
* @extends {KitGeneralError}
*/
export declare class NetworkAuthenticationRequiredError extends KitGeneralError {
/**
* Initializes a new NetworkAuthenticationRequiredError instance.
* @param {string} [message] - The error message. Defaults to the HTTP status code description for 511.
* @param {unknown} [details] - Additional error details.
*/
constructor(message?: string, details?: unknown);
}