Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors: adds OriginalError support #423

Merged
merged 3 commits into from
Dec 3, 2018

Conversation

chris-ramon
Copy link
Member

@chris-ramon chris-ramon commented Nov 28, 2018

Overview

  • Build on top of: Added Custom Error Formatter #379 — Thanks a lot @racerxdl! 👍

  • This PR adds support for retrieving the original error via FormattedError.OriginalError().

    • No breaking changes.

    • Does not expose original errors when JSON serializing since it is available only by a method and the internal field originalError is unexported.

  • Matches graphql-js reference implementation originalError (naming and private variable):

    declare class GraphQLError extends Error {
      constructor(
        message: string,
        nodes?: $ReadOnlyArray<ASTNode> | ASTNode | void | null,
        source?: ?Source,
        positions?: ?$ReadOnlyArray<number>,
        path?: ?$ReadOnlyArray<string | number>,
        originalError?: ?Error, <---------------------------------------------------------
        extensions?: ?{ [key: string]: mixed },
      ): void;

    Ref: Link

Test plan

  • Unit tests.
  • Adds tests for handling errors from resolver.
    • Returning an errors.New(...) error.
    • Returning a custom error.
    • Returning a custom error with extensions.
    • Panic from resolver.

@chris-ramon chris-ramon changed the title errors: adds OriginalError supports errors: adds OriginalError support Nov 28, 2018
@limoli
Copy link

limoli commented Nov 29, 2018

When are you going to merge this? :) @chris-ramon

@chris-ramon chris-ramon force-pushed the formatted-error-private-original-error branch from 4ee17d6 to bfe0f60 Compare December 2, 2018 23:30
@coveralls
Copy link

coveralls commented Dec 2, 2018

Coverage Status

Coverage remained the same at 91.87% when pulling 7995f6a on formatted-error-private-original-error into 8000299 on master.

@chris-ramon chris-ramon merged commit 0894364 into master Dec 3, 2018
@chris-ramon chris-ramon deleted the formatted-error-private-original-error branch December 3, 2018 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants