@authereum/resolution
Version:
Domain Resolution for blockchain domains
67 lines (66 loc) • 3.41 kB
JavaScript
;
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
var ConfigurationErrorCode;
(function (ConfigurationErrorCode) {
ConfigurationErrorCode["IncorrectProvider"] = "IncorrectProvider";
ConfigurationErrorCode["UnspecifiedNetwork"] = "UnspecifiedNetwork";
ConfigurationErrorCode["UnspecifiedUrl"] = "UnspecifiedUrl";
ConfigurationErrorCode["MissingProviderConfigurations"] = "MissingProviderConfigurations";
ConfigurationErrorCode["DependencyMissing"] = "DependencyMissing";
})(ConfigurationErrorCode = exports.ConfigurationErrorCode || (exports.ConfigurationErrorCode = {}));
/**
* @internal
* Internal Mapping object from ConfigurationErrorCode to a ConfigurationErrorHandler
*/
var HandlersByCode = (_a = {},
_a[ConfigurationErrorCode.IncorrectProvider] = function (params) {
return 'Provider doesn\'t implement sendAsync or send method';
},
_a[ConfigurationErrorCode.UnspecifiedNetwork] = function (params) { return "Unspecified network in Resolution " + params.method + " configuration"; },
_a[ConfigurationErrorCode.UnspecifiedUrl] = function (params) { return "Unspecified url in Resolution " + params.method + " configuration"; },
_a[ConfigurationErrorCode.MissingProviderConfigurations] = function (params) {
return "Couldn't find any configurations\n\tUse -C to configurate the library";
},
_a[ConfigurationErrorCode.DependencyMissing] = function (params) {
return "Missing dependency for this functionality. Please install " + params.dependecy + " @ " + params.version + " via npm or yarn";
},
_a);
/**
* Configuration Error class is designed to control every error being thrown by wrong configurations for objects
* @param code - Error Code
* - IncorrectProvider - When provider doesn't have implemented send or sendAsync methods
* - UnspecifiedNetwork - When network is not specified for naming service configurations
* - UnspecifiedUrl - When url is not specified for custom naming service configurations
* @param method - optional param to specify which namingService errored out
*/
var ConfigurationError = /** @class */ (function (_super) {
__extends(ConfigurationError, _super);
function ConfigurationError(code, options) {
if (options === void 0) { options = {}; }
var _this = this;
var configurationErrorHandler = HandlersByCode[code];
_this = _super.call(this, configurationErrorHandler(options)) || this;
_this.code = code;
_this.method = options.method;
_this.name = 'ConfigurationError';
Object.setPrototypeOf(_this, ConfigurationError.prototype);
return _this;
}
return ConfigurationError;
}(Error));
exports.ConfigurationError = ConfigurationError;
exports.default = ConfigurationError;