Skip to content

Commit d84cfca

Browse files
Jackson KearlIvanGoncharov
authored andcommitted
Sync tstypes/errors with flow
1 parent 7b389be commit d84cfca

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

tstypes/error/GraphQLError.d.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Maybe from '../tsutils/Maybe';
2-
import { getLocation } from '../language';
2+
33
import { ASTNode } from '../language/ast';
44
import { Source } from '../language/source';
5-
import { SourceLocation } from '../language/location';
5+
import { SourceLocation, getLocation } from '../language/location';
66

77
/**
88
* A GraphQLError describes an Error found during the parse, validate, or
@@ -11,6 +11,16 @@ import { SourceLocation } from '../language/location';
1111
* GraphQL document and/or execution result that correspond to the Error.
1212
*/
1313
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+
1424
/**
1525
* A message describing the Error for debugging purposes.
1626
*
@@ -47,6 +57,9 @@ export class GraphQLError extends Error {
4757

4858
/**
4959
* 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.
5063
*/
5164
readonly source: Source | undefined;
5265

@@ -65,14 +78,10 @@ export class GraphQLError extends Error {
6578
* Extension fields to add to the formatted error.
6679
*/
6780
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-
);
7881
}
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;

tstypes/error/formatError.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { GraphQLError } from './GraphQLError';
21
import { SourceLocation } from '../language/location';
2+
import { GraphQLError } from './GraphQLError';
33

44
/**
55
* Given a GraphQLError, format it according to the rules described by the

tstypes/error/index.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
export { GraphQLError } from './GraphQLError';
1+
export { GraphQLError, printError } from './GraphQLError';
22
export { syntaxError } from './syntaxError';
33
export { locatedError } from './locatedError';
4-
export { printError } from './printError';
54
export { formatError, GraphQLFormattedError } from './formatError';

tstypes/error/locatedError.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { GraphQLError } from './GraphQLError';
21
import { ASTNode } from '../language/ast';
2+
import { GraphQLError } from './GraphQLError';
33

44
/**
55
* Given an arbitrary Error, presumably thrown while attempting to execute a

tstypes/error/printError.d.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)