1 | import Maybe from '../tsutils/Maybe';
|
2 |
|
3 | import { ASTNode } from '../language/ast';
|
4 | import { Source } from '../language/source';
|
5 | import { SourceLocation, getLocation } from '../language/location';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
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 |
|
24 | /**
|
25 | * A message describing the Error for debugging purposes.
|
26 | *
|
27 | * Enumerable, and appears in the result of JSON.stringify().
|
28 | *
|
29 | * Note: should be treated as readonly, despite invariant usage.
|
30 | */
|
31 | message: string;
|
32 |
|
33 | /**
|
34 | * An array of { line, column } locations within the source GraphQL document
|
35 | * which correspond to this error.
|
36 | *
|
37 | * Errors during validation often contain multiple locations, for example to
|
38 | * point out two things with the same name. Errors during execution include a
|
39 | * single location, the field which produced the error.
|
40 | *
|
41 | * Enumerable, and appears in the result of JSON.stringify().
|
42 | */
|
43 | readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
44 |
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | readonly path: ReadonlyArray<string | number> | undefined;
|
52 |
|
53 | |
54 |
|
55 |
|
56 | readonly nodes: ReadonlyArray<ASTNode> | undefined;
|
57 |
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | readonly source: Source | undefined;
|
65 |
|
66 | |
67 |
|
68 |
|
69 |
|
70 | readonly positions: ReadonlyArray<number> | undefined;
|
71 |
|
72 | |
73 |
|
74 |
|
75 | readonly originalError: Maybe<Error>;
|
76 |
|
77 | |
78 |
|
79 |
|
80 | readonly extensions: { [key: string]: any } | undefined;
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | export function printError(error: GraphQLError): string;
|