-
Notifications
You must be signed in to change notification settings - Fork 543
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
Make ErrSchema1 checkable via errors.Is() #1721
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Codecov Report
@@ Coverage Diff @@
## main #1721 +/- ##
==========================================
+ Coverage 71.99% 72.04% +0.04%
==========================================
Files 121 121
Lines 9768 9764 -4
==========================================
+ Hits 7032 7034 +2
+ Misses 2060 2056 -4
+ Partials 676 674 -2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think embedding the mediaType that we saw is both unnecessary and makes this really complicated.
Can you update this to just be:
var ErrSchema1 = errors.New("unsupported schema1 mediaType, see https://github.com/google/go-containerregistry/issues/377")
And fix any tests that it breaks?
OK. I will done. |
7ff761d
to
b75f624
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's clever. Added a couple suggestions so that we can keep the exact same error string but have the %w
wrapping make errors.Is
work.
I have a feeling someone, somewhere is checking for the string value of this error specifically because errors.Is
doesn't work, so I want to avoid breaking that.
Signed-off-by: Laitron <[email protected]>
b75f624
to
e81effa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
The
TestGetSchema1
said it should fail based on media type while gave the unsupported MediaType. But it not return the true.This fixes that problem by implementing an
Is()
function onErrSchema1
so that
errors.Is()
can properly identify the error as an ErrSchema1.Usage can now be:
errors.Is(err, &ErrSchema1{schema : "foo"})