1 | import { GraphQLError } from './GraphQLError';
|
2 | /**
|
3 | * Given an arbitrary Error, presumably thrown while attempting to execute a
|
4 | * GraphQL operation, produce a new GraphQLError aware of the location in the
|
5 | * document responsible for the original Error.
|
6 | */
|
7 |
|
8 | export function locatedError(originalError, nodes, path) {
|
9 | // Note: this uses a brand-check to support GraphQL errors originating from
|
10 | // other contexts.
|
11 | if (originalError && Array.isArray(originalError.path)) {
|
12 | return originalError;
|
13 | }
|
14 |
|
15 | return new GraphQLError(originalError && originalError.message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
|
16 | }
|