swc/bundler/tests/.cache/deno/fcf896e3589f50e963c2723a443b9cca9dc5538e.ts

19 lines
727 B
TypeScript
Raw Normal View History

// Loaded from https://deno.land/x/graphql_deno@v15.0.0/lib/error/locatedError.js
import { GraphQLError } from './GraphQLError.js';
/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
* GraphQL operation, produce a new GraphQLError aware of the location in the
* document responsible for the original Error.
*/
export function locatedError(originalError, nodes, path) {
// Note: this uses a brand-check to support GraphQL errors originating from
// other contexts.
if (Array.isArray(originalError.path)) {
return originalError;
}
return new GraphQLError(originalError.message, originalError.nodes ?? nodes, originalError.source, originalError.positions, path, originalError);
}