UNPKG

graphql-request

Version:

Minimal GraphQL client supporting Node and browsers for scripts or simple apps.

22 lines 786 B
export class ClientError extends Error { response; request; constructor(response, request) { const message = `${ClientError.extractMessage(response)}: ${JSON.stringify({ response, request, })}`; super(message); Object.setPrototypeOf(this, ClientError.prototype); this.response = response; this.request = request; // this is needed as Safari doesn't support .captureStackTrace if (typeof Error.captureStackTrace === `function`) { Error.captureStackTrace(this, ClientError); } } static extractMessage(response) { return response.errors?.[0]?.message ?? `GraphQL Error (Code: ${String(response.status)})`; } } //# sourceMappingURL=ClientError.js.map