@cruxpay/js-sdk
Version:
CruxPay Javascript SDK
40 lines (39 loc) • 1.63 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 __());
};
})();
import { BaseError } from "./base-error";
import { PackageErrorCode } from "./package-error-code";
var PackageError = /** @class */ (function (_super) {
__extends(PackageError, _super);
function PackageError(cause, message, code) {
var _this = _super.call(this, cause, message, code, true) || this;
_this.name = _this.constructor.name;
_this.message = message || "";
_this.errorCode = code || 1000;
// Changing the Error name printed in the stacktrace if code is given;
if (code) {
_this.name = PackageErrorCode[code];
if (_this.stack) {
// Appending code as stack prefix if available
_this.stack = ("(" + code + ") ").concat(_this.stack);
}
}
// Stack trace structuring;
if (_this.stack && cause && cause.stack) {
_this.stack = _this.stack.concat("\n\n").concat(cause.stack);
}
return _this;
}
return PackageError;
}(BaseError));
export { PackageError };