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.
1,037 lines • 70.4 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NetworkAuthenticationRequiredError = exports.NotExtendedError = exports.LoopDetectedError = exports.InsufficientStorageError = exports.VariantAlsoNegotiatesError = exports.HttpVersionNotSupportedError = exports.GatewayTimeoutError = exports.ServiceUnavailableError = exports.BadGatewayError = exports.NotImplementedError = exports.InternalServerError = exports.UnavailableForLegalReasonsError = exports.RequestHeaderFieldsTooLargeError = exports.TooManyRequestsError = exports.PreconditionRequiredError = exports.UpgradeRequiredError = exports.TooEarlyError = exports.FailedDependencyError = exports.LockedError = exports.UnprocessableEntityError = exports.MisdirectedRequestError = exports.MethodFailureError = exports.InsufficientSpaceOnResourceError = exports.ImATeapotError = exports.ExpectationFailedError = exports.RequestedRangeNotSatisfiableError = exports.UnsupportedMediaTypeError = exports.RequestUriTooLongError = exports.RequestTooLongError = exports.PreconditionFailedError = exports.LengthRequiredError = exports.GoneError = exports.ConflictError = exports.RequestTimeoutError = exports.ProxyAuthenticationRequiredError = exports.NotAcceptableError = exports.MethodNotAllowedError = exports.NotFoundError = exports.ForbiddenError = exports.PaymentRequiredError = exports.UnauthorizedError = exports.BadRequestError = exports.KitHttpErrorConfig = exports.KitHttpError = void 0;
var http_response_status_code_1 = require("http-response-status-code");
/**
* A flag indicating whether KitHttpError-based errors should be used globally.
* When set to `true`, KitHttpError-based errors will be used; otherwise, standard errors will be used.
* @type {boolean}
*/
var useKitHttpErrors = false;
/**
* A constant representing the length of an empty array.
* @constant {number}
*/
var EMPTY_ARRAY_LENGTH = 0;
/**
* Represents a customizable error with a status code, message, and optional details.
* @extends {Error}
*/
var KitHttpError = /** @class */ (function (_super) {
__extends(KitHttpError, _super);
/**
* Initializes a new instance of the KitHttpError 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.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function KitHttpError(statusCode, message, details) {
var args = [];
for (var _i = 3; _i < arguments.length; _i++) {
args[_i - 3] = arguments[_i];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this, message) || this;
_this.rawInputs = { statusCode: statusCode, message: message, details: details, args: args };
var formatter = KitHttpError.defaultFormatter;
if (formatter) {
Object.assign(_this, formatter.apply(void 0, __spreadArray([statusCode, message, details], args, false)));
}
else {
_this.statusCode = statusCode;
_this.message = message;
_this.details = details;
if (
/* eslint-disable-next-line */
args &&
Array.isArray(args) &&
args.length > EMPTY_ARRAY_LENGTH) {
Object.assign.apply(Object, __spreadArray([_this], args, false));
}
}
Object.setPrototypeOf(_this, _newTarget.prototype);
return _this;
}
/**
* Configures a global formatter function for all instances of KitHttpError.
* This formatter will be used to format error details unless an instance-specific formatter is provided.
* @param {(statusCode: number, message: string, details?: unknown, ...args: unknown[]) => unknown} formatter - A function to format error details, which takes the status code, message, optional details, and additional arguments as parameters.
*/
KitHttpError._configureFormatter = function (formatter) {
KitHttpError.defaultFormatter = formatter;
};
/**
* Sets a custom formatter function for this instance, which will be used to format error details.
* This will override any global formatter function set by `KitHttpErrorConfig.configureFormatter()`.
* @param {IFormatter} formatter - A function to format error details, which takes the status code, message, optional details, and additional arguments as parameters.
* @returns {this} The current instance for method chaining.
*/
KitHttpError.prototype.setFormatter = function (formatter) {
this.instanceFormatter = formatter;
Object.assign(this, formatter.apply(void 0, __spreadArray([this.rawInputs.statusCode,
this.rawInputs.message,
this.rawInputs.details], this.rawInputs.args, false)));
return this;
};
/**
* Returns the raw input data associated with this instance.
* @returns {IRawInput} The raw input data associated with this instance.
*/
KitHttpError.prototype.getInputs = function () {
return this.rawInputs;
};
/**
* Returns a JSON-compatible object representation of this instance.
* If a formatter function is provided (either globally or instance-specific),
* it will be used to format the error details.
* Otherwise, the object will contain the `statusCode`, `message`, and `details` properties.
* @returns {{statusCode: number, message: string, details: unknown}} A JSON-compatible object representation of this instance.
*/
KitHttpError.prototype.toJSON = function () {
var formatter = this.instanceFormatter || KitHttpError.defaultFormatter;
if (formatter) {
return formatter.apply(void 0, __spreadArray([this.rawInputs.statusCode,
this.rawInputs.message,
this.rawInputs.details], this.rawInputs.args, false));
}
return {
statusCode: this.rawInputs.statusCode,
message: this.rawInputs.message,
details: this.rawInputs.details,
};
};
return KitHttpError;
}(Error));
exports.KitHttpError = KitHttpError;
/**
* Configuration class for KitHttpError.
* Provides methods to configure the formatter function used by KitHttpError instances.
*/
var KitHttpErrorConfig = /** @class */ (function () {
function KitHttpErrorConfig() {
}
/**
* Configures a global formatter function for all instances of KitHttpError.
* This formatter will be used to format error details unless an instance-specific formatter is provided.
* When this method is called, KitHttpError-based errors will be used globally.
* @param {(statusCode: number, message: string, details?: unknown, ...args: unknown[]) => unknown} formatter - A function to format error details, which takes the status code, message, optional details, and additional arguments as parameters.
*/
KitHttpErrorConfig.configureFormatter = function (formatter) {
KitHttpError._configureFormatter(formatter);
useKitHttpErrors = true; // Switch to using KitHttpError-based errors globally
};
/**
* Checks if KitHttpError-based errors are being used globally.
*
* @returns {boolean} True if KitHttpError-based errors are enabled globally, false otherwise.
*/
KitHttpErrorConfig.shouldUseKitHttpErrors = function () {
return useKitHttpErrors;
};
return KitHttpErrorConfig;
}());
exports.KitHttpErrorConfig = KitHttpErrorConfig;
/**
* Creates a new instance of the KitHttpError class with a status code of 400, Bad Request.
* @extends KitHttpError
*/
var BadRequestError = /** @class */ (function (_super) {
__extends(BadRequestError, _super);
/**
* Creates a new instance of the BadRequestError class.
* @param {string} message - The error message. Defaults to "Bad Request" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function BadRequestError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_400,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_400).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, BadRequestError.prototype);
return _this;
}
return BadRequestError;
}(KitHttpError));
exports.BadRequestError = BadRequestError;
/**
* Creates a new instance of the KitHttpError class with a status code of 401, Unauthorized.
* @extends KitHttpError
*/
var UnauthorizedError = /** @class */ (function (_super) {
__extends(UnauthorizedError, _super);
/**
* Creates a new instance of the UnauthorizedError class.
* @param {string} [message] - The error message. Defaults to "Unauthorized" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function UnauthorizedError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_401,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_401).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, UnauthorizedError.prototype);
return _this;
}
return UnauthorizedError;
}(KitHttpError));
exports.UnauthorizedError = UnauthorizedError;
/**
* Creates a new instance of the KitHttpError class with a status code of 402, Payment Required.
* @extends KitHttpError
*/
var PaymentRequiredError = /** @class */ (function (_super) {
__extends(PaymentRequiredError, _super);
/**
* Creates a new instance of the PaymentRequiredError class.
* @param {string} [message] - The error message. Defaults to "Payment Required" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function PaymentRequiredError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_402,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_402).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, PaymentRequiredError.prototype);
return _this;
}
return PaymentRequiredError;
}(KitHttpError));
exports.PaymentRequiredError = PaymentRequiredError;
/**
* Creates a new instance of the KitHttpError class with a status code of 403, Forbidden.
* @extends KitHttpError
*/
var ForbiddenError = /** @class */ (function (_super) {
__extends(ForbiddenError, _super);
/**
* Creates a new instance of the ForbiddenError class.
* @param {string} [message] - The error message. Defaults to "Forbidden" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function ForbiddenError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_403,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_403).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, ForbiddenError.prototype);
return _this;
}
return ForbiddenError;
}(KitHttpError));
exports.ForbiddenError = ForbiddenError;
/**
* Creates a new instance of the KitHttpError class with a status code of 404, Not Found.
* @extends KitHttpError
*/
var NotFoundError = /** @class */ (function (_super) {
__extends(NotFoundError, _super);
/**
* Creates a new instance of the NotFoundError class.
* @param {string} [message] - The error message. Defaults to "Not Found" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function NotFoundError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_404,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_404).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, NotFoundError.prototype);
return _this;
}
return NotFoundError;
}(KitHttpError));
exports.NotFoundError = NotFoundError;
/**
* Creates a new instance of the KitHttpError class with a status code of 405, Method Not Allowed.
* @extends KitHttpError
*/
var MethodNotAllowedError = /** @class */ (function (_super) {
__extends(MethodNotAllowedError, _super);
/**
* Creates a new instance of the MethodNotAllowedError class.
* @param {string} [message] - The error message. Defaults to "Method Not Allowed" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function MethodNotAllowedError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_405,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_405).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, MethodNotAllowedError.prototype);
return _this;
}
return MethodNotAllowedError;
}(KitHttpError));
exports.MethodNotAllowedError = MethodNotAllowedError;
/**
* Creates a new instance of the KitHttpError class with a status code of 406, Not Acceptable.
* @extends KitHttpError
*/
var NotAcceptableError = /** @class */ (function (_super) {
__extends(NotAcceptableError, _super);
/**
* Creates a new instance of the NotAcceptableError class.
* @param {string} [message] - The error message. Defaults to "Not Acceptable" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function NotAcceptableError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_406,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_406).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, NotAcceptableError.prototype);
return _this;
}
return NotAcceptableError;
}(KitHttpError));
exports.NotAcceptableError = NotAcceptableError;
/**
* Creates a new instance of the KitHttpError class with a status code of 407, Proxy Authentication Required.
* @extends KitHttpError
*/
var ProxyAuthenticationRequiredError = /** @class */ (function (_super) {
__extends(ProxyAuthenticationRequiredError, _super);
/**
* Creates a new instance of the ProxyAuthenticationRequiredError class.
* @param {string} [message] - The error message. Defaults to "Proxy Authentication Required" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function ProxyAuthenticationRequiredError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_407,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_407).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, ProxyAuthenticationRequiredError.prototype);
return _this;
}
return ProxyAuthenticationRequiredError;
}(KitHttpError));
exports.ProxyAuthenticationRequiredError = ProxyAuthenticationRequiredError;
/**
* Creates a new instance of the KitHttpError class with a status code of 408, Request Timeout.
* @extends KitHttpError
*/
var RequestTimeoutError = /** @class */ (function (_super) {
__extends(RequestTimeoutError, _super);
/**
* Creates a new instance of the RequestTimeoutError class.
* @param {string} [message] - The error message. Defaults to "Request Timeout" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function RequestTimeoutError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_408,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_408).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, RequestTimeoutError.prototype);
return _this;
}
return RequestTimeoutError;
}(KitHttpError));
exports.RequestTimeoutError = RequestTimeoutError;
/**
* Creates a new instance of the KitHttpError class with a status code of 409, Conflict.
* @extends KitHttpError
*/
var ConflictError = /** @class */ (function (_super) {
__extends(ConflictError, _super);
/**
* Creates a new instance of the ConflictError class.
* @param {string} [message] - The error message. Defaults to "Conflict" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function ConflictError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_409,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_409).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, ConflictError.prototype);
return _this;
}
return ConflictError;
}(KitHttpError));
exports.ConflictError = ConflictError;
/**
* Creates a new instance of the KitHttpError class with a status code of 410, Gone.
* @extends KitHttpError
*/
var GoneError = /** @class */ (function (_super) {
__extends(GoneError, _super);
/**
* Creates a new instance of the GoneError class.
* @param {string} [message] - The error message. Defaults to "Gone" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function GoneError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_410,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_410).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, GoneError.prototype);
return _this;
}
return GoneError;
}(KitHttpError));
exports.GoneError = GoneError;
/**
* Creates a new instance of the KitHttpError class with a status code of 411, Length Required.
* @extends KitHttpError
*/
var LengthRequiredError = /** @class */ (function (_super) {
__extends(LengthRequiredError, _super);
/**
* Creates a new instance of the LengthRequiredError class.
* @param {string} [message] - The error message. Defaults to "Length Required" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function LengthRequiredError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_411,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_411).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, LengthRequiredError.prototype);
return _this;
}
return LengthRequiredError;
}(KitHttpError));
exports.LengthRequiredError = LengthRequiredError;
/**
* Creates a new instance of the KitHttpError class with a status code of 412, Precondition Failed.
* @extends KitHttpError
*/
var PreconditionFailedError = /** @class */ (function (_super) {
__extends(PreconditionFailedError, _super);
/**
* Creates a new instance of the PreconditionFailedError class.
* @param {string} [message] - The error message. Defaults to "Precondition Failed" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function PreconditionFailedError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_412,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_412).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, PreconditionFailedError.prototype);
return _this;
}
return PreconditionFailedError;
}(KitHttpError));
exports.PreconditionFailedError = PreconditionFailedError;
/**
* Creates a new instance of the KitHttpError class with a status code of 413, Request Entity Too Large.
* @extends KitHttpError
*/
var RequestTooLongError = /** @class */ (function (_super) {
__extends(RequestTooLongError, _super);
/**
* Creates a new instance of the RequestTooLongError class.
* @param {string} [message] - The error message. Defaults to "Request Entity Too Large" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function RequestTooLongError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_413,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_413).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, RequestTooLongError.prototype);
return _this;
}
return RequestTooLongError;
}(KitHttpError));
exports.RequestTooLongError = RequestTooLongError;
/**
* Creates a new instance of the KitHttpError class with a status code of 414, Request-URI Too Long.
* @extends KitHttpError
*/
var RequestUriTooLongError = /** @class */ (function (_super) {
__extends(RequestUriTooLongError, _super);
/**
* Creates a new instance of the RequestUriTooLongError class.
* @param {string} [message] - The error message. Defaults to "Request-URI Too Long" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function RequestUriTooLongError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_414,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_414).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, RequestUriTooLongError.prototype);
return _this;
}
return RequestUriTooLongError;
}(KitHttpError));
exports.RequestUriTooLongError = RequestUriTooLongError;
/**
* Creates a new instance of the KitHttpError class with a status code of 415, Unsupported Media Type.
* @extends KitHttpError
*/
var UnsupportedMediaTypeError = /** @class */ (function (_super) {
__extends(UnsupportedMediaTypeError, _super);
/**
* Creates a new instance of the UnsupportedMediaTypeError class.
* @param {string} [message] - The error message. Defaults to "Unsupported Media Type" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function UnsupportedMediaTypeError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_415,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_415).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, UnsupportedMediaTypeError.prototype);
return _this;
}
return UnsupportedMediaTypeError;
}(KitHttpError));
exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
/**
* Creates a new instance of the KitHttpError class with a status code of 416, Requested Range Not Satisfiable.
* @extends KitHttpError
*/
var RequestedRangeNotSatisfiableError = /** @class */ (function (_super) {
__extends(RequestedRangeNotSatisfiableError, _super);
/**
* Creates a new instance of the RequestedRangeNotSatisfiableError class.
* @param {string} [message] - The error message. Defaults to "Requested Range Not Satisfiable" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function RequestedRangeNotSatisfiableError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_416,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_416).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, RequestedRangeNotSatisfiableError.prototype);
return _this;
}
return RequestedRangeNotSatisfiableError;
}(KitHttpError));
exports.RequestedRangeNotSatisfiableError = RequestedRangeNotSatisfiableError;
/**
* Creates a new instance of the KitHttpError class with a status code of 417, Expectation Failed.
* @extends KitHttpError
*/
var ExpectationFailedError = /** @class */ (function (_super) {
__extends(ExpectationFailedError, _super);
/**
* Creates a new instance of the ExpectationFailedError class.
* @param {string} [message] - The error message. Defaults to "Expectation Failed" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function ExpectationFailedError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_417,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_417).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, ExpectationFailedError.prototype);
return _this;
}
return ExpectationFailedError;
}(KitHttpError));
exports.ExpectationFailedError = ExpectationFailedError;
/**
* Creates a new instance of the KitHttpError class with a status code of 418, I'm a teapot.
* @extends KitHttpError
*/
var ImATeapotError = /** @class */ (function (_super) {
__extends(ImATeapotError, _super);
/**
* Creates a new instance of the ImATeapotError class.
* @param {string} [message] - The error message. Defaults to "I'm a teapot" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function ImATeapotError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_418,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_418).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, ImATeapotError.prototype);
return _this;
}
return ImATeapotError;
}(KitHttpError));
exports.ImATeapotError = ImATeapotError;
/**
* Creates a new instance of the KitHttpError class with a status code of 419, Insufficient Space on Resource.
* @extends KitHttpError
*/
var InsufficientSpaceOnResourceError = /** @class */ (function (_super) {
__extends(InsufficientSpaceOnResourceError, _super);
/**
* Creates a new instance of the InsufficientSpaceOnResourceError class.
* @param {string} [message] - The error message. Defaults to "Insufficient Space on Resource" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function InsufficientSpaceOnResourceError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_419,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_419).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, InsufficientSpaceOnResourceError.prototype);
return _this;
}
return InsufficientSpaceOnResourceError;
}(KitHttpError));
exports.InsufficientSpaceOnResourceError = InsufficientSpaceOnResourceError;
/**
* Creates a new instance of the KitHttpError class with a status code of 420, Method Failure.
* @extends KitHttpError
*/
var MethodFailureError = /** @class */ (function (_super) {
__extends(MethodFailureError, _super);
/**
* Creates a new instance of the MethodFailureError class.
* @param {string} [message] - The error message. Defaults to "Method Failure" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function MethodFailureError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_420,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_420).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, MethodFailureError.prototype);
return _this;
}
return MethodFailureError;
}(KitHttpError));
exports.MethodFailureError = MethodFailureError;
/**
* Creates a new instance of the KitHttpError class with a status code of 421, Misdirected Request.
* @extends KitHttpError
*/
var MisdirectedRequestError = /** @class */ (function (_super) {
__extends(MisdirectedRequestError, _super);
/**
* Creates a new instance of the MisdirectedRequestError class.
* @param {string} [message] - The error message. Defaults to "Misdirected Request" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function MisdirectedRequestError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_421,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_421).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, MisdirectedRequestError.prototype);
return _this;
}
return MisdirectedRequestError;
}(KitHttpError));
exports.MisdirectedRequestError = MisdirectedRequestError;
/**
* Creates a new instance of the KitHttpError class with a status code of 422, Unprocessable Entity.
* @extends KitHttpError
*/
var UnprocessableEntityError = /** @class */ (function (_super) {
__extends(UnprocessableEntityError, _super);
/**
* Creates a new instance of the UnprocessableEntityError class.
* @param {string} [message] - The error message. Defaults to "Unprocessable Entity" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function UnprocessableEntityError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_422,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_422).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, UnprocessableEntityError.prototype);
return _this;
}
return UnprocessableEntityError;
}(KitHttpError));
exports.UnprocessableEntityError = UnprocessableEntityError;
/**
* Creates a new instance of the KitHttpError class with a status code of 423, Locked.
* @extends KitHttpError
*/
var LockedError = /** @class */ (function (_super) {
__extends(LockedError, _super);
/**
* Creates a new instance of the LockedError class.
* @param {string} [message] - The error message. Defaults to "Locked" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function LockedError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_423,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_423).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, LockedError.prototype);
return _this;
}
return LockedError;
}(KitHttpError));
exports.LockedError = LockedError;
/**
* Creates a new instance of the KitHttpError class with a status code of 424, Failed Dependency.
* @extends KitHttpError
*/
var FailedDependencyError = /** @class */ (function (_super) {
__extends(FailedDependencyError, _super);
/**
* Creates a new instance of the FailedDependencyError class.
* @param {string} [message] - The error message. Defaults to "Failed Dependency" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function FailedDependencyError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_424,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_424).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, FailedDependencyError.prototype);
return _this;
}
return FailedDependencyError;
}(KitHttpError));
exports.FailedDependencyError = FailedDependencyError;
/**
* Creates a new instance of the KitHttpError class with a status code of 425, Too Early.
* @extends KitHttpError
*/
var TooEarlyError = /** @class */ (function (_super) {
__extends(TooEarlyError, _super);
/**
* Creates a new instance of the TooEarlyError class.
* @param {string} [message] - The error message. Defaults to "Too Early" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function TooEarlyError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_425,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_425).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, TooEarlyError.prototype);
return _this;
}
return TooEarlyError;
}(KitHttpError));
exports.TooEarlyError = TooEarlyError;
/**
* Creates a new instance of the KitHttpError class with a status code of 426, Upgrade Required.
* @extends KitHttpError
*/
var UpgradeRequiredError = /** @class */ (function (_super) {
__extends(UpgradeRequiredError, _super);
/**
* Creates a new instance of the UpgradeRequiredError class.
* @param {string} [message] - The error message. Defaults to "Upgrade Required" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function UpgradeRequiredError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_426,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_426).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, UpgradeRequiredError.prototype);
return _this;
}
return UpgradeRequiredError;
}(KitHttpError));
exports.UpgradeRequiredError = UpgradeRequiredError;
/**
* Creates a new instance of the KitHttpError class with a status code of 428, Precondition Required.
* @extends KitHttpError
*/
var PreconditionRequiredError = /** @class */ (function (_super) {
__extends(PreconditionRequiredError, _super);
/**
* Creates a new instance of the PreconditionRequiredError class.
* @param {string} [message] - The error message. Defaults to "Precondition Required" if not provided.
* @param {any} [details] - Additional error details.
* @param {...any} args - Additional arguments to pass to the formatter function.
*/
function PreconditionRequiredError(message, details) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
/* istanbul ignore next */
var _this = _super.apply(this, __spreadArray([
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_428,
/* eslint-disable-next-line */
message !== null && message !== void 0 ? message :
/* eslint-disable-next-line */
(0, http_response_status_code_1.getStatusDescription)(http_response_status_code_1.CODES.HTTP_CODE_428).toString(), details], args, false)) || this;
Object.setPrototypeOf(_this, PreconditionRequiredError.prototype);
return _this;
}
return PreconditionRequiredError;
}(KitHttpError));
exports.PreconditionRequiredError = PreconditionRequiredError;
/**
* Creates a new instance of the KitHttpError class with a status code of 429, Too Many Requests.
* @extends KitHttpError
*/
var TooManyRequestsError = /** @class */ (function (_super) {
__extends(TooManyRequestsError, _super);
/**
* Creates a new instance of the TooManyRequestsError class.
* @param {string} [message] - The error message. Defaults to "Too Many Requests" if not provided.
* @param {any}