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

Add an errors package with a similar API to github.com/pkg/errors #291

Merged
merged 3 commits into from
Sep 13, 2021

Commits on Sep 9, 2021

  1. Add an errors package with a similar API to github.com/pkg/errors

    Go introduced a 'native' way to wrap errors back in v1.13. At that point we were
    already using github.com/pkg/errors to 'wrap' errors with context, and we never
    got around to migrating. In addition to pure inertia, I've personally avoided
    making the switch because I prefer the github.com/pkg/errors API. Specifically I
    like that errors.Wrap handles the "outer context: inner context" error format
    that Go uses by convention, and that errors.Wrap will return nil when passed a
    nil error.
    
    Given that github.com/pkg/errors has long been in maintenance mode, and is (per
    pkg/errors#245) no longer used by its original author
    now seems as good a time as any to migrate. This commit attempts to ease that
    migration for the Crossplane project - and to retain the nice API - by adding a
    package that acts as a small github.com/pkg/errors style shim layer around the
    stdlib pkg/errors (and friends, like fmt.Errorf).
    
    Signed-off-by: Nic Cope <negz@rk0n.org>
    negz committed Sep 9, 2021
    Configuration menu
    Copy the full SHA
    1a64750 View commit details
    Browse the repository at this point in the history
  2. Replace github.com/pkg/errors with our own pkg/errors.

    Signed-off-by: Nic Cope <negz@rk0n.org>
    negz committed Sep 9, 2021
    Configuration menu
    Copy the full SHA
    af4e148 View commit details
    Browse the repository at this point in the history
  3. Remove TODO about cmpopts.EquateErrors

    I tried to address this TODO today, but found that I kind of prefer how our
    implementation works. I've found from time to time while writing tests that
    I was accidentally wrapping my errors with the wrong context (i.e. message),
    which is not something the cmpopts variant tests for.
    
    Signed-off-by: Nic Cope <negz@rk0n.org>
    negz committed Sep 9, 2021
    Configuration menu
    Copy the full SHA
    3aa81c4 View commit details
    Browse the repository at this point in the history