scryfall-client
Version:
A module for making requests to scryfall
49 lines (48 loc) • 1.97 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 (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 __());
};
})();
var ExtendableError = /** @class */ (function (_super) {
__extends(ExtendableError, _super);
function ExtendableError(message) {
var _newTarget = this.constructor;
var _this = _super.call(this, message) || this;
Object.setPrototypeOf(_this, _newTarget.prototype);
_this.name = _this.constructor.name;
// @ts-expect-error this a v8 specific thing
if (typeof Error.captureStackTrace === "function") {
// @ts-expect-error this a v8 specific thing
Error.captureStackTrace(_this, _this.constructor);
}
else {
_this.stack = new Error(message).stack;
}
return _this;
}
return ExtendableError;
}(Error));
var ScryfallError = /** @class */ (function (_super) {
__extends(ScryfallError, _super);
function ScryfallError(scryfallResponse) {
var _this = this;
var message = (scryfallResponse.message ||
scryfallResponse.details);
_this = _super.call(this, message) || this;
Object.assign(_this, scryfallResponse);
return _this;
}
return ScryfallError;
}(ExtendableError));
export default ScryfallError;