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,039 lines • 83.8 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.KitHttpErrorConfig = exports.KitHttpError = exports.KitGeneralError = 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 = void 0;
var http_error_1 = require("./http.error");
Object.defineProperty(exports, "KitHttpError", { enumerable: true, get: function () { return http_error_1.KitHttpError; } });
Object.defineProperty(exports, "KitHttpErrorConfig", { enumerable: true, get: function () { return http_error_1.KitHttpErrorConfig; } });
var general_error_1 = require("./general.error");
Object.defineProperty(exports, "KitGeneralError", { enumerable: true, get: function () { return general_error_1.KitGeneralError; } });
var http_response_status_code_1 = require("http-response-status-code");
/**
* Creates a new instance of the KitGeneralError class with a status code of 400, Bad Request.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_400,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return BadRequestError;
}(Error));
exports.BadRequestError = BadRequestError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 401, Unauthorized.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_401,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return UnauthorizedError;
}(Error));
exports.UnauthorizedError = UnauthorizedError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 402, Payment Required.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_402,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return PaymentRequiredError;
}(Error));
exports.PaymentRequiredError = PaymentRequiredError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 403, Forbidden.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_403,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return ForbiddenError;
}(Error));
exports.ForbiddenError = ForbiddenError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 404, Not Found.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_404,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return NotFoundError;
}(Error));
exports.NotFoundError = NotFoundError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 405, Method Not Allowed.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_405,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return MethodNotAllowedError;
}(Error));
exports.MethodNotAllowedError = MethodNotAllowedError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 406, Not Acceptable.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_406,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return NotAcceptableError;
}(Error));
exports.NotAcceptableError = NotAcceptableError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 407, Proxy Authentication Required.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_407,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return ProxyAuthenticationRequiredError;
}(Error));
exports.ProxyAuthenticationRequiredError = ProxyAuthenticationRequiredError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 408, Request Timeout.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_408,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return RequestTimeoutError;
}(Error));
exports.RequestTimeoutError = RequestTimeoutError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 409, Conflict.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_409,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return ConflictError;
}(Error));
exports.ConflictError = ConflictError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 410, Gone.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_410,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return GoneError;
}(Error));
exports.GoneError = GoneError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 411, Length Required.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_411,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return LengthRequiredError;
}(Error));
exports.LengthRequiredError = LengthRequiredError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 412, Precondition Failed.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_412,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return PreconditionFailedError;
}(Error));
exports.PreconditionFailedError = PreconditionFailedError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 413, Request Entity Too Large.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_413,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return RequestTooLongError;
}(Error));
exports.RequestTooLongError = RequestTooLongError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 414, Request-URI Too Long.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_414,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return RequestUriTooLongError;
}(Error));
exports.RequestUriTooLongError = RequestUriTooLongError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 415, Unsupported Media Type.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_415,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return UnsupportedMediaTypeError;
}(Error));
exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 416, Requested Range Not Satisfiable.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_416,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return RequestedRangeNotSatisfiableError;
}(Error));
exports.RequestedRangeNotSatisfiableError = RequestedRangeNotSatisfiableError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 417, Expectation Failed.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_417,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return ExpectationFailedError;
}(Error));
exports.ExpectationFailedError = ExpectationFailedError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 418, I'm a teapot.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_418,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return ImATeapotError;
}(Error));
exports.ImATeapotError = ImATeapotError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 419, Insufficient Space on Resource.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_419,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return InsufficientSpaceOnResourceError;
}(Error));
exports.InsufficientSpaceOnResourceError = InsufficientSpaceOnResourceError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 420, Method Failure.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_420,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return MethodFailureError;
}(Error));
exports.MethodFailureError = MethodFailureError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 421, Misdirected Request.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_421,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return MisdirectedRequestError;
}(Error));
exports.MisdirectedRequestError = MisdirectedRequestError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 422, Unprocessable Entity.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_422,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return UnprocessableEntityError;
}(Error));
exports.UnprocessableEntityError = UnprocessableEntityError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 423, Locked.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_error_1.KitHttpError
: general_error_1.KitGeneralError;
/* eslint-disable-next-line */
message =
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();
var instance = new (BaseError.bind.apply(BaseError, __spreadArray([void 0,
/* eslint-disable-next-line */
http_response_status_code_1.CODES.HTTP_CODE_423,
message,
details], args, false)))();
Object.assign(_this, instance);
Object.setPrototypeOf(_this, _newTarget.prototype);
Object.setPrototypeOf(Object.getPrototypeOf(_this), BaseError.prototype);
return _this;
}
return LockedError;
}(Error));
exports.LockedError = LockedError;
/**
* Creates a new instance of the KitGeneralError class with a status code of 424, Failed Dependency.
* @extends KitHttpError | KitGeneralError
*/
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];
}
var _newTarget = this.constructor;
/* istanbul ignore next */
var _this = _super.call(this) || this;
var BaseError = http_error_1.KitHttpErrorConfig.shouldUseKitHttpErrors()
? http_err