Skip to content

ErrElf has read hitchhiker's (doesn't panic!)#99

Merged
MusicalNinjaDad merged 3 commits into
mainfrom
errors
Nov 6, 2025
Merged

ErrElf has read hitchhiker's (doesn't panic!)#99
MusicalNinjaDad merged 3 commits into
mainfrom
errors

Conversation

@MusicalNinjaDad

@MusicalNinjaDad MusicalNinjaDad commented Nov 6, 2025

Copy link
Copy Markdown
Owner

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:

  • ErrElf.Error no longer panics on empty error list, returning an empty string instead

Documentation:

  • Remove panic mention from ErrElf documentation comment

@sourcery-ai

sourcery-ai Bot commented Nov 6, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Error 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 handling

classDiagram
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
Loading

Flow diagram for ErrElf.Error() method logic change

flowchart TD
    A["ErrElf.Error() called"] --> B{"IsError()?"}
    B -- Yes --> C["Return error string with path and joined errors"]
    B -- No --> D["Return empty string"]
Loading

File-Level Changes

Change Details Files
Refactor ErrElf.Error() to remove panic on empty errors
  • Replace errs != nil check with e.IsError()
  • Add else branch that returns empty string
  • Remove panic("Don't call .Error()..." ) invocation
elf/elf.go
Update documentation comment for ErrElf behavior
  • Remove comment warning about .Error() panicking on empty ErrElf
elf/elf.go
Record behavior change in changelog
  • Add entry documenting non-panicking .Error()
  • Note use of IsError() for empty-state checks
CHANGELOG

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@MusicalNinjaDad MusicalNinjaDad enabled auto-merge (squash) November 6, 2025 16:35
@codecov

codecov Bot commented Nov 6, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.93%. Comparing base (e2c7cce) to head (3cd5348).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
elf/elf.go 33.33% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MusicalNinjaDad MusicalNinjaDad merged commit e7a2c82 into main Nov 6, 2025
14 of 16 checks passed
@MusicalNinjaDad MusicalNinjaDad deleted the errors branch November 6, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error() should not panic when errs is nil; return a clear error instead

1 participant