-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
refactor(blockservice, merkledag, namesys) deprecate u.ErrNotFound #224
Conversation
@@ -103,7 +103,7 @@ func (n *Node) RemoveNodeLink(name string) error { | |||
return nil | |||
} | |||
} | |||
return u.ErrNotFound | |||
return fmt.Errorf("merkledag: %s not found", name) |
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.
make it a static error so we can check against it.
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.
after your last commits this is not a static error yet. it should be so we can 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.
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.
mistake. one moment
@maybebtc its ok if the error doesnt show the name. being able to compare is the important part. (go solved this incorrectly IMO. errors with params should be comparable statically. this doesnt currently leverage the type system well. experimenting.... type ErrNotFound struct {
key string
}
func (e *ErrNotFound) Error() string {
return fmt.Sprintf("merkledag: %s not found", e.key)
}
// elsewhere
foo, err := doSomething()
if err != nil {
if _, ok err.(mdag.ErrNotFound); ok {
// this is a not found error.
}
} @whyrusleeping @maybebtc thoughts on this pattern \o ? it's annoyingly verbose, but it gives us ability to make errors with params that we can still compare. idk i havent thought about it more than 2 min. this may not be needed at all. |
@jbenet If, in the future, we feel pain and need the information in the error, this is a viable solution. The verbosity may only be worth it if we're feeling real pain. For now, we have enough information to get errors back out the the user. #alphafocus aside, can also do: switch err := err.(type) {
case ParseError:
PrintParseError(err)
} |
refactor(blockservice, merkledag, namesys) deprecate u.ErrNotFound
@maybebtc i usually use https://github.com/jbenet/go-ipfs/pull/224/files to CR and see exactly what's changed. |
Ive been toying with the idea of a wrapped error interface:
This way we could have more information about where each error origination, and still be able to compared the root error types. |
I like this. there really should be a more sophisticated |
Ill keep it around, maybe after the alpha I can work on refitting our error handling system |
Remove signal bootstrapping
In a couple places we have the choice between returning an exported error and returning an error with information. Which do we prefer? @jbenet @whyrusleeping