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

Always wrap user errors #1312

Merged
merged 1 commit into from
Sep 21, 2020
Merged

Always wrap user errors #1312

merged 1 commit into from
Sep 21, 2020

Conversation

lwc
Copy link
Member

@lwc lwc commented Aug 28, 2020

This is an alternative to #1305 that leans into error wrapping instead of away from it.

Requires use of go 1.13 error unwrapping.

On measure I think I prefer this approach, even though it's a bigger BC break:

  • There's less mutex juggling
  • It has never felt right to me that we make the user deal with path when overriding the error presenter
  • The default error presenter is now incredibly simple

Questions:

  • Are we comfortable with supporting 1.13 and up?
  • Should we change the signature of ErrorPresenterFunc to func(ctx context.Context, err *gqlerror.Error) *gqlerror.Error?
    • It always is now, and breaking BC will force users to address the requirement for errors.As

Fixes: #1291

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

@coveralls
Copy link

coveralls commented Aug 28, 2020

Coverage Status

Coverage increased (+0.02%) to 66.277% when pulling e821b97 on error-wrapping into 51b580d on master.

Copy link
Member

@mtibben mtibben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this looks like a superior approach to me comparing to #1305

Are we comfortable with supporting 1.13 and up?

+1 from me. Personally I think supporting the just last 2 versions of Go is totally justifiable, Go has high focus on backwards compatibility and if you really want to use an older go, you can use an older gqlgen release too

Should we change the signature of ErrorPresenterFunc to func(ctx context.Context, err *gqlerror.Error) *gqlerror.Error?

Yes I think so. Lets make the BC break obvious

This is an alternative to #1305 that leans into error wrapping instead of away from it.

Requires use of go 1.13 error unwrapping.

On measure I think I prefer this approach, even though it's a bigger BC break:
- There's less mutex juggling
- It has never felt right to me that we make the user deal with path when overriding the error presenter
- The default error presenter is now incredibly simple

Questions:
- Are we comfortable with supporting 1.13 and up?
- Should we change the signature of `ErrorPresenterFunc` to `func(ctx context.Context, err *gqlerror.Error) *gqlerror.Error`?
    - It always is now, and breaking BC will force users to address the requirement for `errors.As`
@lwc lwc merged commit 669a166 into master Sep 21, 2020
@lwc lwc deleted the error-wrapping branch September 21, 2020 00:37
cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
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.

INPUT_FIELD_DEFINITION directive handler returned errors are clobbered
3 participants