@gqlts/runtime
Version:
Gqlts runtime client
33 lines • 1.26 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientError = void 0;
var tslib_1 = require("tslib");
/**
* Represents a GraphQL error from the client
*/
var ClientError = /** @class */ (function (_super) {
tslib_1.__extends(ClientError, _super);
function ClientError(errors) {
var _this = this;
var message = ClientError.extractMessage(errors);
_this = _super.call(this, errors ? "".concat(message, "\n").concat(errors.map(function (error) { return JSON.stringify(error, null, 2); }).join('\n')) : message) || this;
_this.name = 'ClientError';
_this.errors = errors;
Object.setPrototypeOf(_this, ClientError.prototype);
if (Error.captureStackTrace)
Error.captureStackTrace(_this, ClientError);
return _this;
}
ClientError.extractMessage = function (errors) {
var _a;
try {
return ((_a = errors === null || errors === void 0 ? void 0 : errors[0]) === null || _a === void 0 ? void 0 : _a.message) || 'GraphQL Error';
}
catch (e) {
return 'GraphQL Error';
}
};
return ClientError;
}(Error));
exports.ClientError = ClientError;
//# sourceMappingURL=error.js.map
;