UNPKG

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,079 lines 57.4 kB
"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 __()); }; })(); 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.KitGeneralError = void 0; var http_response_status_code_1 = require("http-response-status-code"); /** * Represents a general error with a status code, message, and optional details. * @extends {Error} */ var KitGeneralError = /** @class */ (function (_super) { __extends(KitGeneralError, _super); /** * 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. */ function KitGeneralError(statusCode, message, details) { /* istanbul ignore next */ var _this = _super.call(this, message) || this; _this.statusCode = statusCode; _this.message = message.toString(); _this.details = details; _this.rawInputs = { statusCode: statusCode, message: message, details: details, args: [] }; Object.setPrototypeOf(_this, KitGeneralError.prototype); return _this; } /** * Returns the raw input data associated with this instance. * @returns {IRawInput} The raw input data associated with this instance. */ KitGeneralError.prototype.getInputs = function () { return this.rawInputs; }; /** * Returns a JSON-compatible object representation of this instance. * @returns {{statusCode: number, message: string, details: unknown}} A JSON-compatible object representation of this instance. */ KitGeneralError.prototype.toJSON = function () { return { statusCode: this.statusCode, message: this.message, details: this.details, }; }; return KitGeneralError; }(Error)); exports.KitGeneralError = KitGeneralError; /** * Creates a new instance of the KitGeneralError class with a status code of 400, Bad Request. * @extends KitGeneralError */ var BadRequestError = /** @class */ (function (_super) { __extends(BadRequestError, _super); /** * 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. */ function BadRequestError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_400, message, details) || this; Object.setPrototypeOf(_this, BadRequestError.prototype); return _this; } return BadRequestError; }(KitGeneralError)); exports.BadRequestError = BadRequestError; /** * Creates a new instance of the KitGeneralError class with a status code of 401, Unauthorized. * @extends KitGeneralError */ var UnauthorizedError = /** @class */ (function (_super) { __extends(UnauthorizedError, _super); /** * 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. */ function UnauthorizedError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_401, message, details) || this; Object.setPrototypeOf(_this, UnauthorizedError.prototype); return _this; } return UnauthorizedError; }(KitGeneralError)); exports.UnauthorizedError = UnauthorizedError; /** * Creates a new instance of the KitGeneralError class with a status code of 402, Payment Required. * @extends KitGeneralError */ var PaymentRequiredError = /** @class */ (function (_super) { __extends(PaymentRequiredError, _super); /** * 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. */ function PaymentRequiredError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_402, message, details) || this; Object.setPrototypeOf(_this, PaymentRequiredError.prototype); return _this; } return PaymentRequiredError; }(KitGeneralError)); exports.PaymentRequiredError = PaymentRequiredError; /** * Creates a new instance of the KitGeneralError class with a status code of 403, Forbidden. * @extends KitGeneralError */ var ForbiddenError = /** @class */ (function (_super) { __extends(ForbiddenError, _super); /** * 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. */ function ForbiddenError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_403, message, details) || this; Object.setPrototypeOf(_this, ForbiddenError.prototype); return _this; } return ForbiddenError; }(KitGeneralError)); exports.ForbiddenError = ForbiddenError; /** * Creates a new instance of the KitGeneralError class with a status code of 404, Not Found. * @extends KitGeneralError */ var NotFoundError = /** @class */ (function (_super) { __extends(NotFoundError, _super); /** * 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. */ function NotFoundError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_404, message, details) || this; Object.setPrototypeOf(_this, NotFoundError.prototype); return _this; } return NotFoundError; }(KitGeneralError)); exports.NotFoundError = NotFoundError; /** * Creates a new instance of the KitGeneralError class with a status code of 405, Method Not Allowed. * @extends KitGeneralError */ var MethodNotAllowedError = /** @class */ (function (_super) { __extends(MethodNotAllowedError, _super); /** * 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. */ function MethodNotAllowedError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_405, message, details) || this; Object.setPrototypeOf(_this, MethodNotAllowedError.prototype); return _this; } return MethodNotAllowedError; }(KitGeneralError)); exports.MethodNotAllowedError = MethodNotAllowedError; /** * Creates a new instance of the KitGeneralError class with a status code of 406, Not Acceptable. * @extends KitGeneralError */ var NotAcceptableError = /** @class */ (function (_super) { __extends(NotAcceptableError, _super); /** * 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. */ function NotAcceptableError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_406, message, details) || this; Object.setPrototypeOf(_this, NotAcceptableError.prototype); return _this; } return NotAcceptableError; }(KitGeneralError)); exports.NotAcceptableError = NotAcceptableError; /** * Creates a new instance of the KitGeneralError class with a status code of 407, Proxy Authentication Required. * @extends KitGeneralError */ var ProxyAuthenticationRequiredError = /** @class */ (function (_super) { __extends(ProxyAuthenticationRequiredError, _super); /** * 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. */ function ProxyAuthenticationRequiredError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_407, message, details) || this; Object.setPrototypeOf(_this, ProxyAuthenticationRequiredError.prototype); return _this; } return ProxyAuthenticationRequiredError; }(KitGeneralError)); exports.ProxyAuthenticationRequiredError = ProxyAuthenticationRequiredError; /** * Creates a new instance of the KitGeneralError class with a status code of 408, Request Timeout. * @extends KitGeneralError */ var RequestTimeoutError = /** @class */ (function (_super) { __extends(RequestTimeoutError, _super); /** * 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. */ function RequestTimeoutError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_408, message, details) || this; Object.setPrototypeOf(_this, RequestTimeoutError.prototype); return _this; } return RequestTimeoutError; }(KitGeneralError)); exports.RequestTimeoutError = RequestTimeoutError; /** * Creates a new instance of the KitGeneralError class with a status code of 409, Conflict. * @extends KitGeneralError */ var ConflictError = /** @class */ (function (_super) { __extends(ConflictError, _super); /** * 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. */ function ConflictError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_409, message, details) || this; Object.setPrototypeOf(_this, ConflictError.prototype); return _this; } return ConflictError; }(KitGeneralError)); exports.ConflictError = ConflictError; /** * Creates a new instance of the KitGeneralError class with a status code of 410, Gone. * @extends KitGeneralError */ var GoneError = /** @class */ (function (_super) { __extends(GoneError, _super); /** * 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. */ function GoneError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_410, message, details) || this; Object.setPrototypeOf(_this, GoneError.prototype); return _this; } return GoneError; }(KitGeneralError)); exports.GoneError = GoneError; /** * Creates a new instance of the KitGeneralError class with a status code of 411, Length Required. * @extends KitGeneralError */ var LengthRequiredError = /** @class */ (function (_super) { __extends(LengthRequiredError, _super); /** * 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. */ function LengthRequiredError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_411, message, details) || this; Object.setPrototypeOf(_this, LengthRequiredError.prototype); return _this; } return LengthRequiredError; }(KitGeneralError)); exports.LengthRequiredError = LengthRequiredError; /** * Creates a new instance of the KitGeneralError class with a status code of 412, Precondition Failed. * @extends KitGeneralError */ var PreconditionFailedError = /** @class */ (function (_super) { __extends(PreconditionFailedError, _super); /** * 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. */ function PreconditionFailedError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_412, message, details) || this; Object.setPrototypeOf(_this, PreconditionFailedError.prototype); return _this; } return PreconditionFailedError; }(KitGeneralError)); exports.PreconditionFailedError = PreconditionFailedError; /** * Creates a new instance of the KitGeneralError class with a status code of 413, Request Entity Too Large. * @extends KitGeneralError */ var RequestTooLongError = /** @class */ (function (_super) { __extends(RequestTooLongError, _super); /** * 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. */ function RequestTooLongError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_413, message, details) || this; Object.setPrototypeOf(_this, RequestTooLongError.prototype); return _this; } return RequestTooLongError; }(KitGeneralError)); exports.RequestTooLongError = RequestTooLongError; /** * Creates a new instance of the KitGeneralError class with a status code of 414, Request-URI Too Long. * @extends KitGeneralError */ var RequestUriTooLongError = /** @class */ (function (_super) { __extends(RequestUriTooLongError, _super); /** * 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. */ function RequestUriTooLongError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_414, message, details) || this; Object.setPrototypeOf(_this, RequestUriTooLongError.prototype); return _this; } return RequestUriTooLongError; }(KitGeneralError)); exports.RequestUriTooLongError = RequestUriTooLongError; /** * Creates a new instance of the KitGeneralError class with a status code of 415, Unsupported Media Type. * @extends KitGeneralError */ var UnsupportedMediaTypeError = /** @class */ (function (_super) { __extends(UnsupportedMediaTypeError, _super); /** * 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. */ function UnsupportedMediaTypeError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_415, message, details) || this; Object.setPrototypeOf(_this, UnsupportedMediaTypeError.prototype); return _this; } return UnsupportedMediaTypeError; }(KitGeneralError)); exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError; /** * Creates a new instance of the KitGeneralError class with a status code of 416, Requested Range Not Satisfiable. * @extends KitGeneralError */ var RequestedRangeNotSatisfiableError = /** @class */ (function (_super) { __extends(RequestedRangeNotSatisfiableError, _super); /** * 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. */ function RequestedRangeNotSatisfiableError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_416, message, details) || this; Object.setPrototypeOf(_this, RequestedRangeNotSatisfiableError.prototype); return _this; } return RequestedRangeNotSatisfiableError; }(KitGeneralError)); exports.RequestedRangeNotSatisfiableError = RequestedRangeNotSatisfiableError; /** * Creates a new instance of the KitGeneralError class with a status code of 417, Expectation Failed. * @extends KitGeneralError */ var ExpectationFailedError = /** @class */ (function (_super) { __extends(ExpectationFailedError, _super); /** * 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. */ function ExpectationFailedError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_417, message, details) || this; Object.setPrototypeOf(_this, ExpectationFailedError.prototype); return _this; } return ExpectationFailedError; }(KitGeneralError)); exports.ExpectationFailedError = ExpectationFailedError; /** * Creates a new instance of the KitGeneralError class with a status code of 418, I'm a teapot. * @extends KitGeneralError */ var ImATeapotError = /** @class */ (function (_super) { __extends(ImATeapotError, _super); /** * 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. */ function ImATeapotError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_418, message, details) || this; Object.setPrototypeOf(_this, ImATeapotError.prototype); return _this; } return ImATeapotError; }(KitGeneralError)); exports.ImATeapotError = ImATeapotError; /** * Creates a new instance of the KitGeneralError class with a status code of 419, Insufficient Space on Resource. * @extends KitGeneralError */ var InsufficientSpaceOnResourceError = /** @class */ (function (_super) { __extends(InsufficientSpaceOnResourceError, _super); /** * 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. */ function InsufficientSpaceOnResourceError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_419, message, details) || this; Object.setPrototypeOf(_this, InsufficientSpaceOnResourceError.prototype); return _this; } return InsufficientSpaceOnResourceError; }(KitGeneralError)); exports.InsufficientSpaceOnResourceError = InsufficientSpaceOnResourceError; /** * Creates a new instance of the KitGeneralError class with a status code of 420, Method Failure. * @extends KitGeneralError */ var MethodFailureError = /** @class */ (function (_super) { __extends(MethodFailureError, _super); /** * 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. */ function MethodFailureError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_420, message, details) || this; Object.setPrototypeOf(_this, MethodFailureError.prototype); return _this; } return MethodFailureError; }(KitGeneralError)); exports.MethodFailureError = MethodFailureError; /** * Creates a new instance of the KitGeneralError class with a status code of 421, Misdirected Request. * @extends KitGeneralError */ var MisdirectedRequestError = /** @class */ (function (_super) { __extends(MisdirectedRequestError, _super); /** * 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. */ function MisdirectedRequestError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_421, message, details) || this; Object.setPrototypeOf(_this, MisdirectedRequestError.prototype); return _this; } return MisdirectedRequestError; }(KitGeneralError)); exports.MisdirectedRequestError = MisdirectedRequestError; /** * Creates a new instance of the KitGeneralError class with a status code of 422, Unprocessable Entity. * @extends KitGeneralError */ var UnprocessableEntityError = /** @class */ (function (_super) { __extends(UnprocessableEntityError, _super); /** * 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. */ function UnprocessableEntityError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_422, message, details) || this; Object.setPrototypeOf(_this, UnprocessableEntityError.prototype); return _this; } return UnprocessableEntityError; }(KitGeneralError)); exports.UnprocessableEntityError = UnprocessableEntityError; /** * Creates a new instance of the KitGeneralError class with a status code of 423, Locked. * @extends KitGeneralError */ var LockedError = /** @class */ (function (_super) { __extends(LockedError, _super); /** * 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. */ function LockedError(message, details) { var _this = this; /* 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(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_423, message, details) || this; Object.setPrototypeOf(_this, LockedError.prototype); return _this; } return LockedError; }(KitGeneralError)); exports.LockedError = LockedError; /** * Creates a new instance of the KitGeneralError class with a status code of 424, Failed Dependency. * @extends {KitGeneralError} */ var FailedDependencyError = /** @class */ (function (_super) { __extends(FailedDependencyError, _super); /** * 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. */ function FailedDependencyError(message, details) { var _this = this; /* 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_424).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_424, message, details) || this; Object.setPrototypeOf(_this, FailedDependencyError.prototype); return _this; } return FailedDependencyError; }(KitGeneralError)); exports.FailedDependencyError = FailedDependencyError; /** * Creates a new instance of the KitGeneralError class with a status code of 425, Too Early. * @extends {KitGeneralError} */ var TooEarlyError = /** @class */ (function (_super) { __extends(TooEarlyError, _super); /** * 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. */ function TooEarlyError(message, details) { var _this = this; /* 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_425).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_425, message, details) || this; Object.setPrototypeOf(_this, TooEarlyError.prototype); return _this; } return TooEarlyError; }(KitGeneralError)); exports.TooEarlyError = TooEarlyError; /** * Creates a new instance of the KitGeneralError class with a status code of 426, Upgrade Required. * @extends {KitGeneralError} */ var UpgradeRequiredError = /** @class */ (function (_super) { __extends(UpgradeRequiredError, _super); /** * 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. */ function UpgradeRequiredError(message, details) { var _this = this; /* 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_426).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_426, message, details) || this; Object.setPrototypeOf(_this, UpgradeRequiredError.prototype); return _this; } return UpgradeRequiredError; }(KitGeneralError)); exports.UpgradeRequiredError = UpgradeRequiredError; /** * Creates a new instance of the KitGeneralError class with a status code of 428, Precondition Required. * @extends {KitGeneralError} */ var PreconditionRequiredError = /** @class */ (function (_super) { __extends(PreconditionRequiredError, _super); /** * 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. */ function PreconditionRequiredError(message, details) { var _this = this; /* 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_428).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_428, message, details) || this; Object.setPrototypeOf(_this, PreconditionRequiredError.prototype); return _this; } return PreconditionRequiredError; }(KitGeneralError)); exports.PreconditionRequiredError = PreconditionRequiredError; /** * Creates a new instance of the KitGeneralError class with a status code of 429, Too Many Requests. * @extends {KitGeneralError} */ var TooManyRequestsError = /** @class */ (function (_super) { __extends(TooManyRequestsError, _super); /** * 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. */ function TooManyRequestsError(message, details) { var _this = this; /* 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_429).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_429, message, details) || this; Object.setPrototypeOf(_this, TooManyRequestsError.prototype); return _this; } return TooManyRequestsError; }(KitGeneralError)); exports.TooManyRequestsError = TooManyRequestsError; /** * Creates a new instance of the KitGeneralError class with a status code of 431, Request Header Fields Too Large. * @extends {KitGeneralError} */ var RequestHeaderFieldsTooLargeError = /** @class */ (function (_super) { __extends(RequestHeaderFieldsTooLargeError, _super); /** * 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. */ function RequestHeaderFieldsTooLargeError(message, details) { var _this = this; /* 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_431).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_431, message, details) || this; Object.setPrototypeOf(_this, RequestHeaderFieldsTooLargeError.prototype); return _this; } return RequestHeaderFieldsTooLargeError; }(KitGeneralError)); exports.RequestHeaderFieldsTooLargeError = RequestHeaderFieldsTooLargeError; /** * Creates a new instance of the KitGeneralError class with a status code of 451, Unavailable For Legal Reasons. * @extends {KitGeneralError} */ var UnavailableForLegalReasonsError = /** @class */ (function (_super) { __extends(UnavailableForLegalReasonsError, _super); /** * 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. */ function UnavailableForLegalReasonsError(message, details) { var _this = this; /* 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_451).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_451, message, details) || this; Object.setPrototypeOf(_this, UnavailableForLegalReasonsError.prototype); return _this; } return UnavailableForLegalReasonsError; }(KitGeneralError)); exports.UnavailableForLegalReasonsError = UnavailableForLegalReasonsError; /** * Creates a new instance of the KitGeneralError class with a status code of 500, Internal Server Error. * @extends {KitGeneralError} */ var InternalServerError = /** @class */ (function (_super) { __extends(InternalServerError, _super); /** * 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. */ function InternalServerError(message, details) { var _this = this; /* 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_500).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_500, message, details) || this; Object.setPrototypeOf(_this, InternalServerError.prototype); return _this; } return InternalServerError; }(KitGeneralError)); exports.InternalServerError = InternalServerError; /** * Creates a new instance of the KitGeneralError class with a status code of 501, Not Implemented. * @extends {KitGeneralError} */ var NotImplementedError = /** @class */ (function (_super) { __extends(NotImplementedError, _super); /** * 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. */ function NotImplementedError(message, details) { var _this = this; /* 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_501).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_501, message, details) || this; Object.setPrototypeOf(_this, NotImplementedError.prototype); return _this; } return NotImplementedError; }(KitGeneralError)); exports.NotImplementedError = NotImplementedError; /** * Creates a new instance of the KitGeneralError class with a status code of 502, Bad Gateway. * @extends {KitGeneralError} */ var BadGatewayError = /** @class */ (function (_super) { __extends(BadGatewayError, _super); /** * 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. */ function BadGatewayError(message, details) { var _this = this; /* 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_502).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_502, message, details) || this; Object.setPrototypeOf(_this, BadGatewayError.prototype); return _this; } return BadGatewayError; }(KitGeneralError)); exports.BadGatewayError = BadGatewayError; /** * Creates a new instance of the KitGeneralError class with a status code of 503, Service Unavailable. * @extends {KitGeneralError} */ var ServiceUnavailableError = /** @class */ (function (_super) { __extends(ServiceUnavailableError, _super); /** * 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. */ function ServiceUnavailableError(message, details) { var _this = this; /* 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_503).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_503, message, details) || this; Object.setPrototypeOf(_this, ServiceUnavailableError.prototype); return _this; } return ServiceUnavailableError; }(KitGeneralError)); exports.ServiceUnavailableError = ServiceUnavailableError; /** * Creates a new instance of the KitGeneralError class with a status code of 504, Gateway Timeout. * @extends {KitGeneralError} */ var GatewayTimeoutError = /** @class */ (function (_super) { __extends(GatewayTimeoutError, _super); /** * 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. */ function GatewayTimeoutError(message, details) { var _this = this; /* 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_504).toString(); /* istanbul ignore next */ _this = _super.call(this, /* eslint-disable-next-line */ http_response_status_code_1.CODES.HTTP_CODE_504, message, details) || this; Object.setPrototypeOf(_this, GatewayTimeoutError.prototype); return _this; } return GatewayTimeoutError; }(KitGeneralError)); exports.GatewayTimeoutError = GatewayTimeoutError; /** * Creates a new instance of the KitGeneralError class with a status code of 505, HTTP Version Not Supported. * @extends {KitGeneralError} */ var HttpVersionNotSupportedError = /** @class */ (function (_super) { __extends(HttpVersionNotSupportedError, _super); /** * Initializes a new HttpVersionNotSupportedError instance. * @param {string} [message]