1
1
import Maybe from '../tsutils/Maybe' ;
2
- import { getLocation } from '../language' ;
2
+
3
3
import { ASTNode } from '../language/ast' ;
4
4
import { Source } from '../language/source' ;
5
- import { SourceLocation } from '../language/location' ;
5
+ import { SourceLocation , getLocation } from '../language/location' ;
6
6
7
7
/**
8
8
* A GraphQLError describes an Error found during the parse, validate, or
@@ -11,6 +11,16 @@ import { SourceLocation } from '../language/location';
11
11
* GraphQL document and/or execution result that correspond to the Error.
12
12
*/
13
13
export class GraphQLError extends Error {
14
+ constructor (
15
+ message : string ,
16
+ nodes ?: ReadonlyArray < ASTNode > | ASTNode | undefined ,
17
+ source ?: Maybe < Source > ,
18
+ positions ?: Maybe < ReadonlyArray < number > > ,
19
+ path ?: Maybe < ReadonlyArray < string | number > > ,
20
+ originalError ?: Maybe < Error > ,
21
+ extensions ?: Maybe < { [ key : string ] : any } > ,
22
+ ) ;
23
+
14
24
/**
15
25
* A message describing the Error for debugging purposes.
16
26
*
@@ -47,6 +57,9 @@ export class GraphQLError extends Error {
47
57
48
58
/**
49
59
* The source GraphQL document corresponding to this error.
60
+ *
61
+ * Note that if this Error represents more than one node, the source may not
62
+ * represent nodes after the first node.
50
63
*/
51
64
readonly source : Source | undefined ;
52
65
@@ -65,14 +78,10 @@ export class GraphQLError extends Error {
65
78
* Extension fields to add to the formatted error.
66
79
*/
67
80
readonly extensions : { [ key : string ] : any } | undefined ;
68
-
69
- constructor (
70
- message : string ,
71
- nodes ?: ReadonlyArray < ASTNode > | ASTNode | undefined ,
72
- source ?: Maybe < Source > ,
73
- positions ?: Maybe < ReadonlyArray < number > > ,
74
- path ?: Maybe < ReadonlyArray < string | number > > ,
75
- originalError ?: Maybe < Error > ,
76
- extensions ?: Maybe < { [ key : string ] : any } > ,
77
- ) ;
78
81
}
82
+
83
+ /**
84
+ * Prints a GraphQLError to a string, representing useful location information
85
+ * about the error's position in the source.
86
+ */
87
+ export function printError ( error : GraphQLError ) : string ;
0 commit comments