-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: improve error handling #5878
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
Conversation
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.
Pull Request Overview
This PR introduces a new gerrors
package for structured error wrapping (with details, messages, and exit codes) and replaces prior ad-hoc error-handling logic across internal pipes and CLI commands.
- Add
internal/gerrors
withWrap
,WrapExit
, and detail/exit/message accessors - Remove old
errDetailed
frominternal/pipe
and switch usage togerrors
- Update CLI (
cmd/
) to usegerrors
for exit codes, messages, and details, removing legacy helpers
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
internal/pipe/pipe_test.go | Removed legacy tests for NewDetailedError |
internal/pipe/pipe.go | Dropped old DetailsOf and NewDetailedError implementations |
internal/pipe/build/build.go | Swapped pipe.NewDetailedError for gerrors.Wrap |
internal/gerrors/errors.go | Added new gerrors implementation |
internal/gerrors/errors_test.go | Added tests for gerrors.Wrap and accessors |
cmd/root.go | Replaced custom exit handler with gerrors.ExitOf /MessageOf |
cmd/error.go | Removed legacy exitError type |
cmd/release.go | Updated releaseProject to use decorateWithCtxErr and after |
cmd/check.go | Rewrote error aggregation to use gerrors |
cmd/build.go | Updated buildProject to use decorateWithCtxErr , after , and gerrors |
Comments suppressed due to low confidence (4)
cmd/root.go:4
- The import "cmp" does not exist in the standard library. If you need an Or helper for strings, consider importing the correct package or implement a small helper locally (e.g.,
func or(a, b string) string { if a != "" { return a }; return b }
).
"cmp"
cmd/check.go:10
- This file uses
fmt.Errorf
anderrors.New
but does not import "fmt" or "errors". Add these imports to avoid undefined identifier errors.
"github.com/goreleaser/goreleaser/v2/internal/gerrors"
cmd/release.go:104
decorateWithCtxErr
andafter
are defined incmd/root.go
but not visible here. You need to either define them in this file or move them to a shared utility thatcmd/release.go
can import.
return decorateWithCtxErr(parent, err, "release", after(start))
cmd/build.go:122
decorateWithCtxErr
andafter
are not defined in this file. Either define these helpers here or extract them to a shared package so bothbuild.go
andrelease.go
can access them.
return decorateWithCtxErr(parent, err, "build", after(start))
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Deploying goreleaser with
|
Latest commit: |
9f899a0
|
Status: | ✅ Deploy successful! |
Preview URL: | https://c0d6efb9.goreleaser.pages.dev |
Branch Preview URL: | https://errhandling.goreleaser.pages.dev |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5878 +/- ##
==========================================
- Coverage 82.76% 82.71% -0.05%
==========================================
Files 165 165
Lines 16526 16521 -5
==========================================
- Hits 13677 13666 -11
- Misses 2258 2262 +4
- Partials 591 593 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gerrors
package