1 | function _buildMessageForResponseErrors(data) {
|
2 | return (`Request failed due to following response errors:\n` +
|
3 | data.errors.map((e) => ` - ${e.message}`).join("\n"));
|
4 | }
|
5 | export class GraphqlResponseError extends Error {
|
6 | constructor(request, headers, response) {
|
7 | super(_buildMessageForResponseErrors(response));
|
8 | this.request = request;
|
9 | this.headers = headers;
|
10 | this.response = response;
|
11 | this.name = "GraphqlResponseError";
|
12 |
|
13 | this.errors = response.errors;
|
14 | this.data = response.data;
|
15 |
|
16 |
|
17 | if (Error.captureStackTrace) {
|
18 | Error.captureStackTrace(this, this.constructor);
|
19 | }
|
20 | }
|
21 | }
|