@gqlts/runtime
Version:
Gqlts runtime client
27 lines • 884 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientError = void 0;
/**
* Represents a GraphQL error from the client
*/
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';
}
}
}
exports.ClientError = ClientError;
//# sourceMappingURL=error.js.map