Skip to content

Commit

Permalink
Expand error types to match actual error data
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarkow committed May 20, 2020
1 parent a18ee7e commit cada290
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/errors/ApolloError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { GraphQLError } from 'graphql';

import { isNonEmptyArray } from '../utilities/common/arrays';
import { ServerParseError } from '../link/http/parseAndCheckHttpResponse';
import { ServerError } from '../link/utils/throwServerError';

export function isApolloError(err: Error): err is ApolloError {
return err.hasOwnProperty('graphQLErrors');
Expand Down Expand Up @@ -34,7 +36,7 @@ const generateErrorMessage = (err: ApolloError) => {
export class ApolloError extends Error {
public message: string;
public graphQLErrors: ReadonlyArray<GraphQLError>;
public networkError: Error | null;
public networkError: Error | ServerParseError | ServerError | null;

// An object that can be used to provide some additional information
// about an error, e.g. specifying the type of error this is. Used
Expand All @@ -51,7 +53,7 @@ export class ApolloError extends Error {
extraInfo,
}: {
graphQLErrors?: ReadonlyArray<GraphQLError>;
networkError?: Error | null;
networkError?: Error | ServerParseError | ServerError | null;
errorMessage?: string;
extraInfo?: any;
}) {
Expand Down

0 comments on commit cada290

Please sign in to comment.