-
Notifications
You must be signed in to change notification settings - Fork 80
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: modify enr error message #493
Conversation
Codecov Report
@@ Coverage Diff @@
## main #493 +/- ##
==========================================
+ Coverage 55.75% 55.81% +0.06%
==========================================
Files 85 84 -1
Lines 7614 7578 -36
==========================================
- Hits 4245 4230 -15
+ Misses 2790 2773 -17
+ Partials 579 575 -4
Continue to review full report at Codecov.
|
cmd/enr.go
Outdated
if err != nil { | ||
return err | ||
return errors.New(helpMsg) |
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.
You are assuming that this is the only error that can occur, which is not true. Also please use structured errors always.
Suggest
key, err := p2p.LoadP2PKey(dir)
if os.IsNotExist(err) {
return errors.New("ENR private key not found. Maybe create one with `charon create enr`", z.Str("path", p2p.KeyPath(dataDir))
} else if err != nil {
return err
}
Also please add a test for this!
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.
For os.IsNotExist(err)
to work, the error coming from calling p2p.LoadPrivKey
should not be wrapped. wrapping changes the error type from *fs.PathError
to structured
.
But, when i attempt to simply return err, like,
func LoadPrivKey(dataDir string) (*ecdsa.PrivateKey, error) {
key, err := crypto.LoadECDSA(KeyPath(dataDir))
if err != nil {
// return nil, errors.Wrap(err, "load key")
// But, this throws an error by golangci-lint's wrapcheck linter
return nil, err
}
return key, nil
}
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.
Please add test
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.
LGTM
Assist users running
charon enr
in creating their ENRs. See ticket for more details.Probably may also need to do more than just a helpful message. Thoughts are welcome!
category: refactor
ticket: #490
feature_set: alpha