1 | "use strict";
|
2 | var __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 | })();
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | var ClientError = (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 |
|
21 |
|
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));
|
37 | exports.ClientError = ClientError;
|
38 |
|
\ | No newline at end of file |