locatedError.js 830 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.locatedError = locatedError;
  6. var _GraphQLError = require("./GraphQLError");
  7. /**
  8. * Given an arbitrary Error, presumably thrown while attempting to execute a
  9. * GraphQL operation, produce a new GraphQLError aware of the location in the
  10. * document responsible for the original Error.
  11. */
  12. function locatedError(originalError, nodes, path) {
  13. var _nodes;
  14. // Note: this uses a brand-check to support GraphQL errors originating from
  15. // other contexts.
  16. if (Array.isArray(originalError.path)) {
  17. return originalError;
  18. }
  19. return new _GraphQLError.GraphQLError(originalError.message, (_nodes = originalError.nodes) !== null && _nodes !== void 0 ? _nodes : nodes, originalError.source, originalError.positions, path, originalError);
  20. }