UNPKG

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