UNPKG

1.47 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = Object.setPrototypeOf ||
4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6 return function (d, b) {
7 extendStatics(d, b);
8 function __() { this.constructor = d; }
9 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10 };
11})();
12Object.defineProperty(exports, "__esModule", { value: true });
13var ClientError = /** @class */ (function (_super) {
14 __extends(ClientError, _super);
15 function ClientError(result) {
16 var _this = this;
17 var message = ClientError.extractMessage(result);
18 _this = _super.call(this, message) || this;
19 _this.result = result;
20 // this is needed as Safari doesn't support .captureStackTrace
21 /* tslint:disable-next-line */
22 if (typeof Error.captureStackTrace === 'function') {
23 Error.captureStackTrace(_this, ClientError);
24 }
25 return _this;
26 }
27 ClientError.extractMessage = function (response) {
28 try {
29 return response.errors[0].message;
30 }
31 catch (e) {
32 return "GraphQL Error: " + JSON.stringify(response, null, 2);
33 }
34 };
35 return ClientError;
36}(Error));
37exports.ClientError = ClientError;
38//# sourceMappingURL=ClientError.js.map
\No newline at end of file