mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
19 lines
727 B
TypeScript
19 lines
727 B
TypeScript
|
// 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);
|
||
|
}
|