Skip to content

Commit

Permalink
Sync tstypes/errors with flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Kearl authored and IvanGoncharov committed Aug 22, 2019
1 parent 7b389be commit d84cfca
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
33 changes: 21 additions & 12 deletions tstypes/error/GraphQLError.d.ts
@@ -1,8 +1,8 @@
import Maybe from '../tsutils/Maybe';
import { getLocation } from '../language';

import { ASTNode } from '../language/ast';
import { Source } from '../language/source';
import { SourceLocation } from '../language/location';
import { SourceLocation, getLocation } from '../language/location';

/**
* A GraphQLError describes an Error found during the parse, validate, or
Expand All @@ -11,6 +11,16 @@ import { SourceLocation } from '../language/location';
* GraphQL document and/or execution result that correspond to the Error.
*/
export class GraphQLError extends Error {
constructor(
message: string,
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<{ [key: string]: any }>,
);

/**
* A message describing the Error for debugging purposes.
*
Expand Down Expand Up @@ -47,6 +57,9 @@ export class GraphQLError extends Error {

/**
* The source GraphQL document corresponding to this error.
*
* Note that if this Error represents more than one node, the source may not
* represent nodes after the first node.
*/
readonly source: Source | undefined;

Expand All @@ -65,14 +78,10 @@ export class GraphQLError extends Error {
* Extension fields to add to the formatted error.
*/
readonly extensions: { [key: string]: any } | undefined;

constructor(
message: string,
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<{ [key: string]: any }>,
);
}

/**
* Prints a GraphQLError to a string, representing useful location information
* about the error's position in the source.
*/
export function printError(error: GraphQLError): string;
2 changes: 1 addition & 1 deletion tstypes/error/formatError.d.ts
@@ -1,5 +1,5 @@
import { GraphQLError } from './GraphQLError';
import { SourceLocation } from '../language/location';
import { GraphQLError } from './GraphQLError';

/**
* Given a GraphQLError, format it according to the rules described by the
Expand Down
3 changes: 1 addition & 2 deletions tstypes/error/index.d.ts
@@ -1,5 +1,4 @@
export { GraphQLError } from './GraphQLError';
export { GraphQLError, printError } from './GraphQLError';
export { syntaxError } from './syntaxError';
export { locatedError } from './locatedError';
export { printError } from './printError';
export { formatError, GraphQLFormattedError } from './formatError';
2 changes: 1 addition & 1 deletion tstypes/error/locatedError.d.ts
@@ -1,5 +1,5 @@
import { GraphQLError } from './GraphQLError';
import { ASTNode } from '../language/ast';
import { GraphQLError } from './GraphQLError';

/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
Expand Down
7 changes: 0 additions & 7 deletions tstypes/error/printError.d.ts

This file was deleted.

0 comments on commit d84cfca

Please sign in to comment.