Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 24865af

Browse files
Merge pull request #233 from secrethub/feature/update-error-checking
Update error comparison
2 parents 99de7d0 + 7f90079 commit 24865af

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

internals/secrethub/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ func (cmd *LsCommand) Run() error {
8383
dirPath, err := cmd.path.ToDirPath()
8484
if err == nil {
8585
dirFS, err := client.Dirs().GetTree(dirPath.Value(), 1, false)
86-
if err == api.ErrDirNotFound && dirPath.IsRepoPath() {
86+
if api.IsErrNotFound(err) && dirPath.IsRepoPath() {
8787
return err
88-
} else if err != nil && err != api.ErrDirNotFound {
88+
} else if err != nil && !isErrNotFound(err) {
8989
return err
9090
} else if err == nil {
9191
err = printDir(cmd.io.Stdout(), cmd.quiet, dirFS.RootDir, timeFormatter)
@@ -100,7 +100,7 @@ func (cmd *LsCommand) Run() error {
100100
secretPath, err := cmd.path.ToSecretPath()
101101
if err == nil {
102102
versions, err := client.Secrets().Versions().ListWithoutData(secretPath.Value())
103-
if err == api.ErrSecretNotFound {
103+
if api.IsErrNotFound(err) {
104104
return ErrResourceNotFound(cmd.path)
105105
} else if err != nil {
106106
return err

internals/secrethub/rm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (cmd *RmCommand) Run() error {
7171
return ErrCannotRemoveDir
7272
}
7373
return rmDir(client, dirPath, cmd.force, cmd.io)
74-
} else if err != api.ErrDirNotFound {
74+
} else if !api.IsErrNotFound(err) {
7575
return err
7676
}
7777
}
@@ -87,7 +87,7 @@ func (cmd *RmCommand) Run() error {
8787

8888
// Check if the secret exists first so we can return a generic error here instead of ErrSecretNotFound.
8989
_, err = client.Secrets().Get(secretPath.Value())
90-
if err == api.ErrSecretNotFound {
90+
if api.IsErrNotFound(err) {
9191
return ErrResourceNotFound(cmd.path)
9292
}
9393

0 commit comments

Comments
 (0)