forked from adamlaska/ts-graphql-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
52 lines (44 loc) · 1.22 KB
/
index.ts
File metadata and controls
52 lines (44 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
export { ErrorReporter } from './error-reporter';
export type ErrorRange = {
fileName: string;
start: number;
end: number;
};
export type Severity = 'Error' | 'Warn';
export type ErrorContent = ErrorRange & {
severity?: Severity;
content: string;
};
export class ErrorWithLocation extends Error {
readonly name = 'ErrorWithLocation';
readonly severity: Severity = 'Error';
constructor(public readonly message: string, public readonly errorContent: ErrorContent) {
super(message);
if (errorContent.severity) {
this.severity = errorContent.severity;
}
}
}
export class ErrorWithoutLocation extends Error {
readonly name = 'ErrorWithoutLocation';
constructor(public readonly message: string, public readonly severity: Severity = 'Error') {
super(message);
}
}
export type TsGqlError = ErrorWithLocation | ErrorWithoutLocation;
export const ERROR_CODES = {
graphqlLangServiceError: {
code: 51001,
},
templateIsTooComplex: {
code: 51010,
message: 'This operation or fragment has too complex interpolation to analyze.',
},
errorInOtherInterpolation: {
code: 51011,
message: 'This expression has some GraphQL errors.',
},
schemaBuildError: {
code: 51020,
},
};