Skip to content

Commit 27bfaa7

Browse files
committed
fix: avoid new error creation
Signed-off-by: vg006 <devvg006@gmail.com>
1 parent 56380a9 commit 27bfaa7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cmd/harbor/root/artifact/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ Supports pagination, search queries, and sorting using flags.`,
5656
if len(args) > 0 {
5757
projectName, repoName, err = utils.ParseProjectRepo(args[0])
5858
if err != nil {
59-
return errors.New("Invalid project/repository format", "expected format: <project>/<repository>")
59+
return err
6060
}
6161
} else {
6262
projectName, err = prompt.GetProjectNameFromUser()
6363
if err != nil {
64-
return errors.AsError(err).WithMessage("failed to get project name")
64+
return err
6565
}
6666
repoName = prompt.GetRepoNameFromUser(projectName)
6767
}
6868

6969
artifacts, err = api.ListArtifact(projectName, repoName, opts)
7070

7171
if err != nil {
72-
return errors.AsError(err).WithMessage("failed to list artifacts")
72+
return err
7373
}
7474

7575
FormatFlag := viper.GetString("output-format")

pkg/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func PrintPayloadInYAMLFormat(payload any) {
6666
func ParseProjectRepo(projectRepo string) (project, repo string, err error) {
6767
split := strings.SplitN(projectRepo, "/", 2) // splits only at first slash
6868
if len(split) != 2 {
69-
return "", "", errors.Newf("invalid project/repository format: %s", projectRepo)
69+
return "", "", errors.New(fmt.Sprintf("Invalid project/repository format: %s", projectRepo), "expected format: <project>/<repository>")
7070
}
7171
return split[0], split[1], nil
7272
}

0 commit comments

Comments
 (0)