[pkgsite-metrics] internal/worker: use errors.Join in cleanup

0 views
Skip to first unread message

Jonathan Amsterdam (Gerrit)

unread,
Mar 28, 2023, 3:32:13 PM3/28/23
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Maceo Thompson, Zvonimir Pavlinovic, Gopher Robot, golang-co...@googlegroups.com

Jonathan Amsterdam submitted this change.

View Change

Approvals: Zvonimir Pavlinovic: Looks good to me, approved Gopher Robot: TryBots succeeded Maceo Thompson: Looks good to me, approved Jonathan Amsterdam: Run TryBots
internal/worker: use errors.Join in cleanup

Change-Id: I0674409a51de1b42c7437ad1ac4733e0cd3788a9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/479235
TryBot-Result: Gopher Robot <go...@golang.org>
Run-TryBot: Jonathan Amsterdam <j...@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavl...@google.com>
Reviewed-by: Maceo Thompson <maceot...@google.com>
---
M internal/worker/scan.go
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/internal/worker/scan.go b/internal/worker/scan.go
index 6501c73..1a4847a 100644
--- a/internal/worker/scan.go
+++ b/internal/worker/scan.go
@@ -251,11 +251,5 @@
// cleanup calls f and combines the error with errp.
// It is meant to be deferred.
func cleanup(errp *error, f func() error) {
- if err := f(); err != nil {
- if *errp == nil {
- *errp = err
- } else {
- *errp = fmt.Errorf("cleanup: %v, and also %w", err, *errp)
- }
- }
+ *errp = errors.Join(*errp, f())
}

To view, visit change 479235. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pkgsite-metrics
Gerrit-Branch: master
Gerrit-Change-Id: I0674409a51de1b42c7437ad1ac4733e0cd3788a9
Gerrit-Change-Number: 479235
Gerrit-PatchSet: 2
Gerrit-Owner: Jonathan Amsterdam <j...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Jonathan Amsterdam <j...@google.com>
Gerrit-Reviewer: Maceo Thompson <maceot...@google.com>
Gerrit-Reviewer: Zvonimir Pavlinovic <zpavl...@google.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages