error.js 488 B

1234567891011121314
  1. export class GraphqlError extends Error {
  2. constructor(request, response) {
  3. const message = response.data.errors[0].message;
  4. super(message);
  5. Object.assign(this, response.data);
  6. this.name = "GraphqlError";
  7. this.request = request;
  8. // Maintains proper stack trace (only available on V8)
  9. /* istanbul ignore next */
  10. if (Error.captureStackTrace) {
  11. Error.captureStackTrace(this, this.constructor);
  12. }
  13. }
  14. }