@belgattitude/http-exception
Version:
Warning: has been moved to @httpx/exception. Please update.
898 lines (841 loc) • 33.6 kB
JavaScript
'use strict';
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct.bind();
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class);
};
return _wrapNativeSuper(Class);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
var supportsErrorCause = function supportsErrorCause() {
var _Error;
var cause = Symbol('');
return ((_Error = new Error('', {
cause: cause
})) === null || _Error === void 0 ? void 0 : _Error.cause) === cause;
};
var getMsgFromCls = function getMsgFromCls(className) {
return className.replace(/[A-Z]/g, function (match) {
return " ".concat(match);
}).trim().split(' ').map(function (word, idx) {
return idx === 0 ? word : word.toLowerCase();
}).join(' ');
};
var getSuper = function getSuper(name, msgOrParams) {
var p = typeof msgOrParams === 'string' ? {
message: msgOrParams
} : msgOrParams;
var _ref = p !== null && p !== void 0 ? p : {},
_ref$message = _ref.message,
message = _ref$message === void 0 ? getMsgFromCls(name) : _ref$message,
url = _ref.url,
cause = _ref.cause,
errorId = _ref.errorId,
code = _ref.code,
method = _ref.method;
return {
message: message,
url: url,
cause: cause,
errorId: errorId,
code: code,
method: method
};
};
var HttpException = function (_Error) {
_inherits(HttpException, _Error);
function HttpException(statusCode, msgOrParams) {
var _this;
var name = 'HttpException';
var _getSuper = getSuper(name, msgOrParams),
message = _getSuper.message,
url = _getSuper.url,
cause = _getSuper.cause,
errorId = _getSuper.errorId,
code = _getSuper.code,
method = _getSuper.method;
_this = _Error.call(this, message) || this;
_this.statusCode = void 0;
_this.url = void 0;
_this.method = void 0;
_this.code = void 0;
_this.errorId = void 0;
_this.cause = void 0;
if (supportsErrorCause() && cause instanceof Error) {
_this.cause = cause;
}
_this.statusCode = statusCode;
_this.url = url;
_this.errorId = errorId;
_this.code = code;
_this.method = method;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpException.prototype);
_this.name = name;
return _this;
}
return _createClass(HttpException);
}(_wrapNativeSuper(Error));
var HttpServerException = function (_HttpException) {
_inherits(HttpServerException, _HttpException);
function HttpServerException(statusCode, msgOrParams) {
var _this;
_this = _HttpException.call(this, statusCode, getSuper('HttpServerException', msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpServerException.prototype);
_this.name = 'HttpServerException';
return _this;
}
return _createClass(HttpServerException);
}(HttpException);
var HttpClientException = function (_HttpException) {
_inherits(HttpClientException, _HttpException);
function HttpClientException(statusCode, msgOrParams) {
var _this;
var name = 'HttpClientException';
_this = _HttpException.call(this, statusCode, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpClientException.prototype);
_this.name = name;
return _this;
}
return _createClass(HttpClientException);
}(HttpException);
var HttpBadRequest = function (_HttpClientException) {
_inherits(HttpBadRequest, _HttpClientException);
function HttpBadRequest(msgOrParams) {
var _this;
var name = 'BadRequest';
_this = _HttpClientException.call(this, 400, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpBadRequest.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpBadRequest);
}(HttpClientException);
HttpBadRequest.STATUS = 400;
var HttpConflict = function (_HttpClientException) {
_inherits(HttpConflict, _HttpClientException);
function HttpConflict(msgOrParams) {
var _this;
var name = 'Conflict';
_this = _HttpClientException.call(this, 409, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpConflict.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpConflict);
}(HttpClientException);
HttpConflict.STATUS = 409;
var HttpExpectationFailed = function (_HttpClientException) {
_inherits(HttpExpectationFailed, _HttpClientException);
function HttpExpectationFailed(msgOrParams) {
var _this;
var name = 'ExpectationFailed';
_this = _HttpClientException.call(this, 417, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpExpectationFailed.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpExpectationFailed);
}(HttpClientException);
HttpExpectationFailed.STATUS = 417;
var HttpFailedDependency = function (_HttpClientException) {
_inherits(HttpFailedDependency, _HttpClientException);
function HttpFailedDependency(msgOrParams) {
var _this;
var name = 'FailedDependency';
_this = _HttpClientException.call(this, 424, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpFailedDependency.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpFailedDependency);
}(HttpClientException);
HttpFailedDependency.STATUS = 424;
var HttpForbidden = function (_HttpClientException) {
_inherits(HttpForbidden, _HttpClientException);
function HttpForbidden(msgOrParams) {
var _this;
var name = 'Forbidden';
_this = _HttpClientException.call(this, 403, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpForbidden.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpForbidden);
}(HttpClientException);
HttpForbidden.STATUS = 403;
var HttpGone = function (_HttpClientException) {
_inherits(HttpGone, _HttpClientException);
function HttpGone(msgOrParams) {
var _this;
var name = 'Gone';
_this = _HttpClientException.call(this, 410, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpGone.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpGone);
}(HttpClientException);
HttpGone.STATUS = 410;
var HttpImATeapot = function (_HttpClientException) {
_inherits(HttpImATeapot, _HttpClientException);
function HttpImATeapot(msgOrParams) {
var _this;
var name = 'ImATeapot';
_this = _HttpClientException.call(this, 418, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpImATeapot.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpImATeapot);
}(HttpClientException);
HttpImATeapot.STATUS = 418;
var HttpLengthRequired = function (_HttpClientException) {
_inherits(HttpLengthRequired, _HttpClientException);
function HttpLengthRequired(msgOrParams) {
var _this;
var name = 'LengthRequired';
_this = _HttpClientException.call(this, 411, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpLengthRequired.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpLengthRequired);
}(HttpClientException);
HttpLengthRequired.STATUS = 411;
var HttpLocked = function (_HttpClientException) {
_inherits(HttpLocked, _HttpClientException);
function HttpLocked(msgOrParams) {
var _this;
var name = 'Locked';
_this = _HttpClientException.call(this, 423, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpLocked.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpLocked);
}(HttpClientException);
HttpLocked.STATUS = 423;
var HttpMisdirectedRequest = function (_HttpClientException) {
_inherits(HttpMisdirectedRequest, _HttpClientException);
function HttpMisdirectedRequest(msgOrParams) {
var _this;
var name = 'MisdirectedRequest';
_this = _HttpClientException.call(this, 421, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpMisdirectedRequest.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpMisdirectedRequest);
}(HttpClientException);
HttpMisdirectedRequest.STATUS = 421;
var HttpMethodNotAllowed = function (_HttpClientException) {
_inherits(HttpMethodNotAllowed, _HttpClientException);
function HttpMethodNotAllowed(msgOrParams) {
var _this;
var name = 'MethodNotAllowed';
_this = _HttpClientException.call(this, 405, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpMethodNotAllowed.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpMethodNotAllowed);
}(HttpClientException);
HttpMethodNotAllowed.STATUS = 405;
var HttpNotAcceptable = function (_HttpClientException) {
_inherits(HttpNotAcceptable, _HttpClientException);
function HttpNotAcceptable(msgOrParams) {
var _this;
var name = 'NotAcceptable';
_this = _HttpClientException.call(this, 406, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpNotAcceptable.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpNotAcceptable);
}(HttpClientException);
HttpNotAcceptable.STATUS = 406;
var HttpNotFound = function (_HttpClientException) {
_inherits(HttpNotFound, _HttpClientException);
function HttpNotFound(msgOrParams) {
var _this;
var name = 'NotFound';
_this = _HttpClientException.call(this, 404, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpNotFound.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpNotFound);
}(HttpClientException);
HttpNotFound.STATUS = 404;
var HttpPayloadTooLarge = function (_HttpClientException) {
_inherits(HttpPayloadTooLarge, _HttpClientException);
function HttpPayloadTooLarge(msgOrParams) {
var _this;
var name = 'PayloadTooLarge';
_this = _HttpClientException.call(this, 413, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpPayloadTooLarge.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpPayloadTooLarge);
}(HttpClientException);
HttpPayloadTooLarge.STATUS = 413;
var HttpPaymentRequired = function (_HttpClientException) {
_inherits(HttpPaymentRequired, _HttpClientException);
function HttpPaymentRequired(msgOrParams) {
var _this;
var name = 'PaymentRequired';
_this = _HttpClientException.call(this, 402, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpPaymentRequired.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpPaymentRequired);
}(HttpClientException);
HttpPaymentRequired.STATUS = 402;
var HttpPreconditionFailed = function (_HttpClientException) {
_inherits(HttpPreconditionFailed, _HttpClientException);
function HttpPreconditionFailed(msgOrParams) {
var _this;
var name = 'PreconditionFailed';
_this = _HttpClientException.call(this, 412, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpPreconditionFailed.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpPreconditionFailed);
}(HttpClientException);
HttpPreconditionFailed.STATUS = 412;
var HttpPreconditionRequired = function (_HttpClientException) {
_inherits(HttpPreconditionRequired, _HttpClientException);
function HttpPreconditionRequired(msgOrParams) {
var _this;
var name = 'PreconditionRequired';
_this = _HttpClientException.call(this, 428, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpPreconditionRequired.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpPreconditionRequired);
}(HttpClientException);
HttpPreconditionRequired.STATUS = 428;
var HttpProxyAuthenticationRequired = function (_HttpClientException) {
_inherits(HttpProxyAuthenticationRequired, _HttpClientException);
function HttpProxyAuthenticationRequired(msgOrParams) {
var _this;
var name = 'ProxyAuthenticationRequired';
_this = _HttpClientException.call(this, 407, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpProxyAuthenticationRequired.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpProxyAuthenticationRequired);
}(HttpClientException);
HttpProxyAuthenticationRequired.STATUS = 407;
var HttpRangeNotSatisfiable = function (_HttpClientException) {
_inherits(HttpRangeNotSatisfiable, _HttpClientException);
function HttpRangeNotSatisfiable(msgOrParams) {
var _this;
var name = 'RangeNotSatisfiable';
_this = _HttpClientException.call(this, 416, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpRangeNotSatisfiable.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpRangeNotSatisfiable);
}(HttpClientException);
HttpRangeNotSatisfiable.STATUS = 416;
var HttpRequestHeaderFieldsTooLarge = function (_HttpClientException) {
_inherits(HttpRequestHeaderFieldsTooLarge, _HttpClientException);
function HttpRequestHeaderFieldsTooLarge(msgOrParams) {
var _this;
var name = 'RequestHeaderFieldsTooLarge';
_this = _HttpClientException.call(this, 431, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpRequestHeaderFieldsTooLarge.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpRequestHeaderFieldsTooLarge);
}(HttpClientException);
HttpRequestHeaderFieldsTooLarge.STATUS = 431;
var HttpRequestTimeout = function (_HttpClientException) {
_inherits(HttpRequestTimeout, _HttpClientException);
function HttpRequestTimeout(msgOrParams) {
var _this;
var name = 'RequestTimeout';
_this = _HttpClientException.call(this, 408, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpRequestTimeout.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpRequestTimeout);
}(HttpClientException);
HttpRequestTimeout.STATUS = 408;
var HttpTooEarly = function (_HttpClientException) {
_inherits(HttpTooEarly, _HttpClientException);
function HttpTooEarly(msgOrParams) {
var _this;
var name = 'TooEarly';
_this = _HttpClientException.call(this, 425, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpTooEarly.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpTooEarly);
}(HttpClientException);
HttpTooEarly.STATUS = 425;
var HttpTooManyRequests = function (_HttpClientException) {
_inherits(HttpTooManyRequests, _HttpClientException);
function HttpTooManyRequests(msgOrParams) {
var _this;
var name = 'TooManyRequests';
_this = _HttpClientException.call(this, 429, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpTooManyRequests.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpTooManyRequests);
}(HttpClientException);
HttpTooManyRequests.STATUS = 429;
var HttpUnauthorized = function (_HttpClientException) {
_inherits(HttpUnauthorized, _HttpClientException);
function HttpUnauthorized(msgOrParams) {
var _this;
var name = 'Unauthorized';
_this = _HttpClientException.call(this, 401, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpUnauthorized.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpUnauthorized);
}(HttpClientException);
HttpUnauthorized.STATUS = 401;
var HttpUnavailableForLegalReasons = function (_HttpClientException) {
_inherits(HttpUnavailableForLegalReasons, _HttpClientException);
function HttpUnavailableForLegalReasons(msgOrParams) {
var _this;
var name = 'UnavailableForLegalReasons';
_this = _HttpClientException.call(this, 451, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpUnavailableForLegalReasons.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpUnavailableForLegalReasons);
}(HttpClientException);
HttpUnavailableForLegalReasons.STATUS = 451;
var HttpUnprocessableEntity = function (_HttpClientException) {
_inherits(HttpUnprocessableEntity, _HttpClientException);
function HttpUnprocessableEntity(msgOrParams) {
var _this;
var name = 'UnprocessableEntity';
_this = _HttpClientException.call(this, 422, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpUnprocessableEntity.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpUnprocessableEntity);
}(HttpClientException);
HttpUnprocessableEntity.STATUS = 422;
var HttpUnsupportedMediaType = function (_HttpClientException) {
_inherits(HttpUnsupportedMediaType, _HttpClientException);
function HttpUnsupportedMediaType(msgOrParams) {
var _this;
var name = 'UnsupportedMediaType';
_this = _HttpClientException.call(this, 415, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpUnsupportedMediaType.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpUnsupportedMediaType);
}(HttpClientException);
HttpUnsupportedMediaType.STATUS = 415;
var HttpUpgradeRequired = function (_HttpClientException) {
_inherits(HttpUpgradeRequired, _HttpClientException);
function HttpUpgradeRequired(msgOrParams) {
var _this;
var name = 'UpgradeRequired';
_this = _HttpClientException.call(this, 426, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpUpgradeRequired.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpUpgradeRequired);
}(HttpClientException);
HttpUpgradeRequired.STATUS = 426;
var HttpUriTooLong = function (_HttpClientException) {
_inherits(HttpUriTooLong, _HttpClientException);
function HttpUriTooLong(msgOrParams) {
var _this;
var name = 'UriTooLong';
_this = _HttpClientException.call(this, 414, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpUriTooLong.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpUriTooLong);
}(HttpClientException);
HttpUriTooLong.STATUS = 414;
var HttpBadGateway = function (_HttpServerException) {
_inherits(HttpBadGateway, _HttpServerException);
function HttpBadGateway(msgOrParams) {
var _this;
var name = 'BadGateway';
_this = _HttpServerException.call(this, 502, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpBadGateway.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpBadGateway);
}(HttpServerException);
HttpBadGateway.STATUS = 502;
var HttpVersionNotSupported = function (_HttpServerException) {
_inherits(HttpVersionNotSupported, _HttpServerException);
function HttpVersionNotSupported(msgOrParams) {
var _this;
var name = 'HttpVersionNotSupported';
_this = _HttpServerException.call(this, 505, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpVersionNotSupported.prototype);
_this.name = name;
return _this;
}
return _createClass(HttpVersionNotSupported);
}(HttpServerException);
HttpVersionNotSupported.STATUS = 505;
var HttpGatewayTimeout = function (_HttpServerException) {
_inherits(HttpGatewayTimeout, _HttpServerException);
function HttpGatewayTimeout(msgOrParams) {
var _this;
var name = 'GatewayTimeout';
_this = _HttpServerException.call(this, 504, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpGatewayTimeout.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpGatewayTimeout);
}(HttpServerException);
HttpGatewayTimeout.STATUS = 504;
var HttpInternalServerError = function (_HttpServerException) {
_inherits(HttpInternalServerError, _HttpServerException);
function HttpInternalServerError(msgOrParams) {
var _this;
var name = 'InternalServerError';
_this = _HttpServerException.call(this, 500, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpInternalServerError.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpInternalServerError);
}(HttpServerException);
HttpInternalServerError.STATUS = 500;
var HttpNetworkAuthenticationRequired = function (_HttpServerException) {
_inherits(HttpNetworkAuthenticationRequired, _HttpServerException);
function HttpNetworkAuthenticationRequired(msgOrParams) {
var _this;
var name = 'NetworkAuthenticationRequired';
_this = _HttpServerException.call(this, 511, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpNetworkAuthenticationRequired.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpNetworkAuthenticationRequired);
}(HttpServerException);
HttpNetworkAuthenticationRequired.STATUS = 511;
var HttpNotExtended = function (_HttpServerException) {
_inherits(HttpNotExtended, _HttpServerException);
function HttpNotExtended(msgOrParams) {
var _this;
var name = 'NotExtended';
_this = _HttpServerException.call(this, 510, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpNotExtended.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpNotExtended);
}(HttpServerException);
HttpNotExtended.STATUS = 510;
var HttpNotImplemented = function (_HttpServerException) {
_inherits(HttpNotImplemented, _HttpServerException);
function HttpNotImplemented(msgOrParams) {
var _this;
var name = 'NotImplemented';
_this = _HttpServerException.call(this, 501, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpNotImplemented.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpNotImplemented);
}(HttpServerException);
HttpNotImplemented.STATUS = 501;
var HttpServiceUnavailable = function (_HttpServerException) {
_inherits(HttpServiceUnavailable, _HttpServerException);
function HttpServiceUnavailable(msgOrParams) {
var _this;
var name = 'ServiceUnavailable';
_this = _HttpServerException.call(this, 503, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpServiceUnavailable.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpServiceUnavailable);
}(HttpServerException);
HttpServiceUnavailable.STATUS = 503;
var HttpInsufficientStorage = function (_HttpServerException) {
_inherits(HttpInsufficientStorage, _HttpServerException);
function HttpInsufficientStorage(msgOrParams) {
var _this;
var name = 'InsufficientStorage';
_this = _HttpServerException.call(this, 507, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpInsufficientStorage.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpInsufficientStorage);
}(HttpServerException);
HttpInsufficientStorage.STATUS = 507;
var HttpLoopDetected = function (_HttpServerException) {
_inherits(HttpLoopDetected, _HttpServerException);
function HttpLoopDetected(msgOrParams) {
var _this;
var name = 'LoopDetected';
_this = _HttpServerException.call(this, 508, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpLoopDetected.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpLoopDetected);
}(HttpServerException);
HttpLoopDetected.STATUS = 508;
var HttpVariantAlsoNegotiates = function (_HttpServerException) {
_inherits(HttpVariantAlsoNegotiates, _HttpServerException);
function HttpVariantAlsoNegotiates(msgOrParams) {
var _this;
var name = 'VariantAlsoNegotiates';
_this = _HttpServerException.call(this, 506, getSuper(name, msgOrParams)) || this;
Object.setPrototypeOf(_assertThisInitialized(_this), HttpVariantAlsoNegotiates.prototype);
_this.name = "Http".concat(name);
return _this;
}
return _createClass(HttpVariantAlsoNegotiates);
}(HttpServerException);
HttpVariantAlsoNegotiates.STATUS = 506;
var isHttpException = function isHttpException(error) {
return error instanceof HttpException;
};
var isHttpClientException = function isHttpClientException(error) {
return error instanceof HttpClientException;
};
var isHttpServerException = function isHttpServerException(error) {
return error instanceof HttpServerException;
};
var isHttpStatusCode = function isHttpStatusCode(statusCode) {
if (typeof statusCode !== 'number') {
return false;
}
return statusCode > 99 && statusCode < 600;
};
var isHttpErrorStatusCode = function isHttpErrorStatusCode(statusCode) {
if (typeof statusCode !== 'number') {
return false;
}
return statusCode >= 400 && statusCode < 600;
};
var statusMap = {
400: HttpBadRequest,
401: HttpUnauthorized,
402: HttpPaymentRequired,
403: HttpForbidden,
404: HttpNotFound,
405: HttpMethodNotAllowed,
406: HttpNotAcceptable,
407: HttpProxyAuthenticationRequired,
408: HttpRequestTimeout,
409: HttpConflict,
410: HttpGone,
411: HttpLengthRequired,
412: HttpPreconditionFailed,
413: HttpPayloadTooLarge,
414: HttpUriTooLong,
415: HttpUnsupportedMediaType,
416: HttpRangeNotSatisfiable,
417: HttpExpectationFailed,
418: HttpImATeapot,
421: HttpMisdirectedRequest,
422: HttpUnprocessableEntity,
423: HttpLocked,
424: HttpFailedDependency,
425: HttpTooEarly,
426: HttpUpgradeRequired,
428: HttpPreconditionRequired,
429: HttpTooManyRequests,
431: HttpRequestHeaderFieldsTooLarge,
451: HttpUnavailableForLegalReasons,
500: HttpInternalServerError,
501: HttpNotImplemented,
502: HttpBadGateway,
503: HttpServiceUnavailable,
504: HttpGatewayTimeout,
505: HttpVersionNotSupported,
506: HttpVariantAlsoNegotiates,
507: HttpInsufficientStorage,
508: HttpLoopDetected,
510: HttpNotExtended,
511: HttpNetworkAuthenticationRequired
};
var createHttpException = function createHttpException(statusCode, msgOrParams) {
if (isHttpErrorStatusCode(statusCode)) {
var cls = statusMap === null || statusMap === void 0 ? void 0 : statusMap[statusCode];
if (cls) {
return new cls(msgOrParams);
}
return statusCode < 500 ? new HttpClientException(statusCode, msgOrParams) : new HttpServerException(statusCode, msgOrParams);
}
return new HttpException(statusCode, msgOrParams);
};
exports.HttpBadGateway = HttpBadGateway;
exports.HttpBadRequest = HttpBadRequest;
exports.HttpClientException = HttpClientException;
exports.HttpConflict = HttpConflict;
exports.HttpException = HttpException;
exports.HttpExpectationFailed = HttpExpectationFailed;
exports.HttpFailedDependency = HttpFailedDependency;
exports.HttpForbidden = HttpForbidden;
exports.HttpGatewayTimeout = HttpGatewayTimeout;
exports.HttpGone = HttpGone;
exports.HttpImATeapot = HttpImATeapot;
exports.HttpInsufficientStorage = HttpInsufficientStorage;
exports.HttpInternalServerError = HttpInternalServerError;
exports.HttpLengthRequired = HttpLengthRequired;
exports.HttpLocked = HttpLocked;
exports.HttpLoopDetected = HttpLoopDetected;
exports.HttpMethodNotAllowed = HttpMethodNotAllowed;
exports.HttpMisdirectedRequest = HttpMisdirectedRequest;
exports.HttpNetworkAuthenticationRequired = HttpNetworkAuthenticationRequired;
exports.HttpNotAcceptable = HttpNotAcceptable;
exports.HttpNotExtended = HttpNotExtended;
exports.HttpNotFound = HttpNotFound;
exports.HttpNotImplemented = HttpNotImplemented;
exports.HttpPayloadTooLarge = HttpPayloadTooLarge;
exports.HttpPaymentRequired = HttpPaymentRequired;
exports.HttpPreconditionFailed = HttpPreconditionFailed;
exports.HttpPreconditionRequired = HttpPreconditionRequired;
exports.HttpProxyAuthenticationRequired = HttpProxyAuthenticationRequired;
exports.HttpRangeNotSatisfiable = HttpRangeNotSatisfiable;
exports.HttpRequestHeaderFieldsTooLarge = HttpRequestHeaderFieldsTooLarge;
exports.HttpRequestTimeout = HttpRequestTimeout;
exports.HttpServerException = HttpServerException;
exports.HttpServiceUnavailable = HttpServiceUnavailable;
exports.HttpTooEarly = HttpTooEarly;
exports.HttpTooManyRequests = HttpTooManyRequests;
exports.HttpUnauthorized = HttpUnauthorized;
exports.HttpUnavailableForLegalReasons = HttpUnavailableForLegalReasons;
exports.HttpUnprocessableEntity = HttpUnprocessableEntity;
exports.HttpUnsupportedMediaType = HttpUnsupportedMediaType;
exports.HttpUpgradeRequired = HttpUpgradeRequired;
exports.HttpUriTooLong = HttpUriTooLong;
exports.HttpVariantAlsoNegotiates = HttpVariantAlsoNegotiates;
exports.HttpVersionNotSupported = HttpVersionNotSupported;
exports.createHttpException = createHttpException;
exports.isHttpClientException = isHttpClientException;
exports.isHttpErrorStatusCode = isHttpErrorStatusCode;
exports.isHttpException = isHttpException;
exports.isHttpServerException = isHttpServerException;
exports.isHttpStatusCode = isHttpStatusCode;