-
Notifications
You must be signed in to change notification settings - Fork 212
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
[Merged by Bors] - chore: refactor panics into error handling #6345
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6345 +/- ##
=========================================
- Coverage 81.7% 81.7% -0.1%
=========================================
Files 312 312
Lines 34637 34657 +20
=========================================
+ Hits 28327 28331 +4
- Misses 4479 4489 +10
- Partials 1831 1837 +6 ☔ View full report in Codecov by Sentry. |
fetch/fetch.go
Outdated
bs := datastore.NewBlobStore(cdb, proposals) | ||
|
||
hashPeerCache, err := NewHashPeersCache(cacheSize) | ||
if err != nil { | ||
return nil, fmt.Errorf("create hash peer cache: %w", err) |
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.
IMHO, propagating this up isn't the right choice. It can only fail if the private cacheSize
const is invalid so the problem is:
- a clear programmer error
- entirely isolated to this pkg/file
I think it's totally fine to panic on it rather than complicating other code with an impossible (in normal conditions, when cacheSize >=0
invariant isn't violated) error, wdyt?
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, I changed it to panic, but left the changes regarding returning an error from NewFetch
in the case this config option isn't a constant in the future (at which point I'd prefer returning an error instead of panicing).
bors merge |
## Motivation Updated some places where `log.Panic` is used and replaced it by returning the error, callers already handle them.
Build failed:
|
bors merge |
## Motivation Updated some places where `log.Panic` is used and replaced it by returning the error, callers already handle them.
Build failed: |
bors merge |
## Motivation Updated some places where `log.Panic` is used and replaced it by returning the error, callers already handle them.
Build failed:
|
bors merge |
## Motivation Updated some places where `log.Panic` is used and replaced it by returning the error, callers already handle them.
Pull request successfully merged into develop. Build succeeded:
|
Motivation
Updated some places where
log.Panic
is used and replaced it by returning the error, callers already handle them.Description
Return errors in some places where
log.Panic
was used beforeTest Plan
Existing tests pass.
TODO