-
Notifications
You must be signed in to change notification settings - Fork 26
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
Improve "merkledag: not found" error #55
Conversation
Based on #33, taking advantage of the rather new Is() methods from the errors package to check for equality.
merkledag.go
Outdated
// ErrNotFound is used to signal when a Node could not be found. The specific | ||
// meaning will depend on the DAGService implementation, which may be trying | ||
// to read nodes locally but also, trying to find them remotely. | ||
var ErrNotFound = ErrNotFoundCid{} |
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.
Returning ErrNotFoundCid{Cid}
is already going to break anything comparing against ErrNotFound
. Given that, I'd rather explicitly break it and replace ErrNotFound
with type ErrNotFound struct { Cid }
.
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.
Ok, but no-one returns ErrNotFoundCid (and we can grep-fix all of our things accordingly). So for everyone else things would still work. But yeah, let's play safe and break.
We should consider the comments form #33 and implement a |
Note: we're definitely going to punt this till after 0.5 as it may have other consequences. |
What is the rationale for this approach? I don't fully understand it. Is the rationale here to be able to check if an error implements a I checked the blog post and my take is that wrapping and letting the original packages decide if it's one of their Am I missing something? |
type ErrNotFound struct { | ||
Cid cid.Cid | ||
} |
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.
Exposed Cid thinking that this might be used from outside this module.
It is ugly though that you have to instantiate the struct whenever you want to check if errors.Is(whatever, ErrNotFound{})
.
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.
We can add an IsNotFound
function.
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.
Added, and made it equivalent to Is
.
From async discussion: Really, there are two kinds of checks: "is" and "property".
TL;DR: |
Based on #33, taking advantage of the rather new Is() methods from the errors
package to check for equality.