Skip to content

Commit 5e78b6c

Browse files
authored
feat(db): append errors (#7843)
Signed-off-by: knqyf263 <knqyf263@gmail.com>
1 parent dc44946 commit 5e78b6c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/oci/artifact.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/google/go-containerregistry/pkg/name"
1313
v1 "github.com/google/go-containerregistry/pkg/v1"
1414
"github.com/google/go-containerregistry/pkg/v1/remote/transport"
15+
"github.com/hashicorp/go-multierror"
1516
"github.com/samber/lo"
1617
"golang.org/x/xerrors"
1718

@@ -224,6 +225,7 @@ func NewArtifacts(repos []name.Reference, opt types.RegistryOptions, opts ...Opt
224225
// Download downloads artifacts until one of them succeeds.
225226
// Attempts to download next artifact if the first one fails due to a temporary error.
226227
func (a Artifacts) Download(ctx context.Context, dst string, opt DownloadOption) error {
228+
var errs error
227229
for i, art := range a {
228230
log.InfoContext(ctx, "Downloading artifact...", log.String("repo", art.repository))
229231
err := art.Download(ctx, dst, opt)
@@ -239,9 +241,10 @@ func (a Artifacts) Download(ctx context.Context, dst string, opt DownloadOption)
239241
if i < len(a)-1 {
240242
log.InfoContext(ctx, "Trying to download artifact from other repository...")
241243
}
244+
errs = multierror.Append(errs, err)
242245
}
243246

244-
return xerrors.New("failed to download artifact from any source")
247+
return xerrors.Errorf("failed to download artifact from any source: %w", errs)
245248
}
246249

247250
func shouldTryOtherRepo(err error) bool {

0 commit comments

Comments
 (0)