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

error.Is testing checker #171

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

SimonRichardson
Copy link
Member

@SimonRichardson SimonRichardson commented Aug 15, 2023

The following makes it easier to compare errors. Currently, if we attempt to use satisfies checker, we'll more than likely end up with a deprecation warning that Is prefix predicate variants from the errors package are being used.

The solution is to make a new checker that we can move to, which has the semantics that we want moving forward.

You can use it in the following manner:

err := errors.ConstError("foo")
c.Check(err, jc.ErrorIs, errors.ConstError("foo"))

The following makes it easier to compare errors. Currently, if
we attempt to use satisfies checker, we'll more thank likely endup
with a deprecation warning that Is prefix predicate variants from
the errors package is being used.

The solution is to make a new checker that we can move to, which has
the semantics that we want moving forward.
Copy link
Member

@tlm tlm left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for this. I have been using bool checkers with errors.Is up until now but this flows a lot better.

Love ya work @SimonRichardson

@SimonRichardson SimonRichardson merged commit d0b20a6 into juju:master Aug 16, 2023
@SimonRichardson SimonRichardson deleted the errors-is-checker branch August 16, 2023 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants