Skip to content

Commit 86d5970

Browse files
authored
feat: extracting general errors from GraphQL responses (#806)
* feat: extracting general errors from GraphQL responses * Fixed tests
1 parent 3321abf commit 86d5970

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

packages/javascript-api/src/lib/services/api-base/api-base.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ describe('ApiBase', () => {
522522
await Qminder.ApiBase.queryGraph(ME_ID.request);
523523
}).rejects.toThrow(
524524
new ResponseValidationError(
525-
`Server response is not valid GraphQL response. Response: {}`,
525+
'Error occurred! Could not extract error message!',
526526
),
527527
);
528528
});

packages/javascript-api/src/lib/services/api-base/api-base.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
isSuccessResponse,
99
} from '../../model/graphql-response.js';
1010
import { RequestInit } from '../../model/fetch.js';
11-
import { ResponseValidationError } from '../../model/errors/response-validation-error.js';
1211

1312
type RequestInitWithMethodRequired = Pick<RequestInit, 'method' | 'headers'> & {
1413
body?: string | File | object;
@@ -151,11 +150,7 @@ export class ApiBase {
151150
return graphQLResponse.data;
152151
}
153152

154-
throw new ResponseValidationError(
155-
`Server response is not valid GraphQL response. Response: ${JSON.stringify(
156-
graphQLResponse,
157-
)}`,
158-
);
153+
throw this.extractError(graphQLResponse);
159154
}
160155

161156
private static extractError(response: any): Error {

0 commit comments

Comments
 (0)