UNPKG

@cruxpay/js-sdk

Version:

CruxPay Javascript SDK

50 lines (49 loc) 1.99 kB
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 __()); }; })(); import { BaseError, PackageError } from "."; var ClientError = /** @class */ (function (_super) { __extends(ClientError, _super); function ClientError(cause, errorMessage, errorCode) { var _this = this; var message = errorMessage || ""; _this = _super.call(this, cause, message, errorCode) || this; _this.name = _this.constructor.name; _this.errorCode = errorCode || ClientError.FALLBACK_ERROR_CODE; return _this; } ClientError.fromError = function (error, messagePrefix) { var msgPrefix = messagePrefix === undefined ? "" : messagePrefix + " : "; if (error instanceof ClientError) { if (error.message !== undefined) { error.message = msgPrefix + error.message; } return error; } else if (error instanceof PackageError) { return new this(error, msgPrefix + error.message, error.errorCode); } else if (typeof (error) === "string") { return new this(null, msgPrefix + error); } else if (error instanceof Error) { return new this(error, msgPrefix + error.message); } else { throw new BaseError(null, "Wrong instance type: " + typeof (error)); } }; ClientError.FALLBACK_ERROR_CODE = 9000; return ClientError; }(BaseError)); export { ClientError };