@gqlts/runtime
Version:
Gqlts runtime client
23 lines • 749 B
JavaScript
/**
* Represents a GraphQL error from the client
*/
export class ClientError extends Error {
constructor(errors) {
const message = ClientError.extractMessage(errors);
super(errors ? `${message}\n${errors.map((error) => JSON.stringify(error, null, 2)).join('\n')}` : message);
this.name = 'ClientError';
this.errors = errors;
Object.setPrototypeOf(this, ClientError.prototype);
if (Error.captureStackTrace)
Error.captureStackTrace(this, ClientError);
}
static extractMessage(errors) {
try {
return errors?.[0]?.message || 'GraphQL Error';
}
catch (e) {
return 'GraphQL Error';
}
}
}
//# sourceMappingURL=error.js.map