diff --git a/internal/cmd/role/create.go b/internal/cmd/role/create.go index 0eba27e5..b9405a35 100644 --- a/internal/cmd/role/create.go +++ b/internal/cmd/role/create.go @@ -54,8 +54,11 @@ func CreateCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("branch %s does not exist in database %s (organization: %s)", - printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) + return cmdutil.HandleNotFoundWithServiceTokenCheck( + cmd.Context(), cmd, ch.Config, ch.Client, err, + "create_branch_password or create_production_branch_password", + "database %s or branch %s does not exist in organization %s", + printer.BoldBlue(database), printer.BoldBlue(branch), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err) } diff --git a/internal/cmd/role/delete.go b/internal/cmd/role/delete.go index 42607356..3b65ed3a 100644 --- a/internal/cmd/role/delete.go +++ b/internal/cmd/role/delete.go @@ -83,7 +83,10 @@ func DeleteCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("role %s does not exist in branch %s of database %s (organization: %s)", + return cmdutil.HandleNotFoundWithServiceTokenCheck( + ctx, cmd, ch.Config, ch.Client, err, + "delete_branch_password or delete_production_branch_password", + "role %s does not exist in branch %s of database %s (organization: %s)", printer.BoldBlue(roleID), printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err) diff --git a/internal/cmd/role/get.go b/internal/cmd/role/get.go index b111e69e..146cdb38 100644 --- a/internal/cmd/role/get.go +++ b/internal/cmd/role/get.go @@ -38,7 +38,10 @@ func GetCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("role %s does not exist in branch %s of database %s (organization: %s)", + return cmdutil.HandleNotFoundWithServiceTokenCheck( + ctx, cmd, ch.Config, ch.Client, err, + "read_branch", + "role %s does not exist in branch %s of database %s (organization: %s)", printer.BoldBlue(roleID), printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err) diff --git a/internal/cmd/role/list.go b/internal/cmd/role/list.go index 3d603e8a..126b0c49 100644 --- a/internal/cmd/role/list.go +++ b/internal/cmd/role/list.go @@ -60,8 +60,11 @@ func ListCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("branch %s does not exist in database %s (organization: %s)", - printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) + return cmdutil.HandleNotFoundWithServiceTokenCheck( + ctx, cmd, ch.Config, ch.Client, err, + "read_branch", + "database %s or branch %s does not exist in organization %s", + printer.BoldBlue(database), printer.BoldBlue(branch), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err) } diff --git a/internal/cmd/role/reassign.go b/internal/cmd/role/reassign.go index e7810f47..f1a8888c 100644 --- a/internal/cmd/role/reassign.go +++ b/internal/cmd/role/reassign.go @@ -86,7 +86,10 @@ func ReassignCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("role %s does not exist in branch %s of database %s (organization: %s)", + return cmdutil.HandleNotFoundWithServiceTokenCheck( + ctx, cmd, ch.Config, ch.Client, err, + "delete_branch_password or delete_production_branch_password", + "role %s does not exist in branch %s of database %s (organization: %s)", printer.BoldBlue(roleID), printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err) diff --git a/internal/cmd/role/renew.go b/internal/cmd/role/renew.go index 6c5f7b18..3eeed8c4 100644 --- a/internal/cmd/role/renew.go +++ b/internal/cmd/role/renew.go @@ -39,7 +39,10 @@ func RenewCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("role %s does not exist in branch %s of database %s (organization: %s)", + return cmdutil.HandleNotFoundWithServiceTokenCheck( + ctx, cmd, ch.Config, ch.Client, err, + "create_branch_password or create_production_branch_password", + "role %s does not exist in branch %s of database %s (organization: %s)", printer.BoldBlue(roleID), printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err) diff --git a/internal/cmd/role/reset.go b/internal/cmd/role/reset.go index e590306d..05742f7f 100644 --- a/internal/cmd/role/reset.go +++ b/internal/cmd/role/reset.go @@ -80,7 +80,10 @@ func ResetCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("role %s does not exist in branch %s of database %s (organization: %s)", + return cmdutil.HandleNotFoundWithServiceTokenCheck( + ctx, cmd, ch.Config, ch.Client, err, + "delete_branch_password or delete_production_branch_password", + "role %s does not exist in branch %s of database %s (organization: %s)", printer.BoldBlue(roleID), printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err) diff --git a/internal/cmd/role/reset_default.go b/internal/cmd/role/reset_default.go index cbfe1cfc..f52c540f 100644 --- a/internal/cmd/role/reset_default.go +++ b/internal/cmd/role/reset_default.go @@ -78,8 +78,11 @@ func ResetDefaultCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("branch %s does not exist in database %s (organization: %s)", - printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) + return cmdutil.HandleNotFoundWithServiceTokenCheck( + cmd.Context(), cmd, ch.Config, ch.Client, err, + "delete_branch_password or delete_production_branch_password", + "database %s or branch %s does not exist in organization %s", + printer.BoldBlue(database), printer.BoldBlue(branch), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err) } diff --git a/internal/cmd/role/update.go b/internal/cmd/role/update.go index cc7e4fa5..28a9cf9b 100644 --- a/internal/cmd/role/update.go +++ b/internal/cmd/role/update.go @@ -47,7 +47,10 @@ func UpdateCmd(ch *cmdutil.Helper) *cobra.Command { if err != nil { switch cmdutil.ErrCode(err) { case ps.ErrNotFound: - return fmt.Errorf("role %s does not exist in branch %s of database %s (organization: %s)", + return cmdutil.HandleNotFoundWithServiceTokenCheck( + ctx, cmd, ch.Config, ch.Client, err, + "create_branch_password or create_production_branch_password", + "role %s does not exist in branch %s of database %s (organization: %s)", printer.BoldBlue(roleID), printer.BoldBlue(branch), printer.BoldBlue(database), printer.BoldBlue(ch.Config.Organization)) default: return cmdutil.HandleError(err)