Skip to content

Commit 69d1e3f

Browse files
committed
fix: use error wrapping when enumerating launchpad project groups
1 parent a27e0e5 commit 69d1e3f

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

internal/launchpad/launchpad.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package launchpad
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"io"
87
"net/http"
@@ -13,13 +12,6 @@ import (
1312

1413
const launchpadTimeout = 5 * time.Second
1514

16-
var errEnumerateProjectGroup = errors.New("error enumerating project group")
17-
18-
// enumerateProjectGroupError builds a wrapped error that might occur when enumerating a group.
19-
func enumerateProjectGroupError(err error) error {
20-
return fmt.Errorf("%w: %s", errEnumerateProjectGroup, err.Error())
21-
}
22-
2315
// Config contains fields used in releasegen's config.yaml file to configure
2416
// its behaviour when generating reports about Launchpad repositories.
2517
type Config struct {
@@ -35,18 +27,18 @@ func enumerateProjectGroup(ctx context.Context, projectGroup string) ([]string,
3527

3628
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
3729
if err != nil {
38-
return nil, enumerateProjectGroupError(err)
30+
return nil, fmt.Errorf("error enumerating project group '%s': %w", projectGroup, err)
3931
}
4032

4133
res, getErr := client.Do(req)
4234
if getErr != nil {
43-
return nil, enumerateProjectGroupError(err)
35+
return nil, fmt.Errorf("error enumerating project group '%s': %w", projectGroup, err)
4436
}
4537
defer res.Body.Close()
4638

4739
body, readErr := io.ReadAll(res.Body)
4840
if readErr != nil {
49-
return nil, enumerateProjectGroupError(err)
41+
return nil, fmt.Errorf("error enumerating project group '%s': %w", projectGroup, err)
5042
}
5143

5244
// Parse the result as JSON, grab the "entries" key.

0 commit comments

Comments
 (0)