ErrElf has read hitchhiker's (doesn't panic!)#99
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideError handling in ErrElf.Error() has been refactored to eliminate panics when no errors are present, switching to an explicit IsError() check and returning an empty string for the empty state. Class diagram for updated ErrElf error handlingclassDiagram
class ErrElf {
- errs []error
- path string
+ Error() string
+ IsError() bool
+ IsEmpty() bool
+ Join(error)
}
ErrElf : Error() now returns "" if IsError() is false (no panic)
ErrElf : IsError() checks if errs is non-empty
Flow diagram for ErrElf.Error() method logic changeflowchart TD
A["ErrElf.Error() called"] --> B{"IsError()?"}
B -- Yes --> C["Return error string with path and joined errors"]
B -- No --> D["Return empty string"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #99 +/- ##
==========================================
- Coverage 75.03% 74.93% -0.11%
==========================================
Files 12 12
Lines 729 730 +1
==========================================
Hits 547 547
Misses 125 125
- Partials 57 58 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Make ErrElf.Error safe to call when no errors by returning an empty string instead of panicking and update documentation.
Bug Fixes:
Documentation: