From 8f759cf7918474e44d0ecdb861c18e5a812ef5d9 Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 21 Dec 2023 13:29:05 -0500 Subject: [PATCH] Normalize delete error messages --- internal/cli/actions.go | 4 +++- internal/cli/apps.go | 4 ++-- internal/cli/custom_domains.go | 4 ++-- internal/cli/log_streams.go | 4 ++-- internal/cli/organizations.go | 4 ++-- internal/cli/roles.go | 4 ++-- internal/cli/rules.go | 4 ++-- internal/cli/users.go | 4 ++-- 8 files changed, 17 insertions(+), 15 deletions(-) diff --git a/internal/cli/actions.go b/internal/cli/actions.go index 89d9654a6..c0c2f7e5c 100644 --- a/internal/cli/actions.go +++ b/internal/cli/actions.go @@ -393,7 +393,9 @@ func deleteActionCmd(cli *cli) *cobra.Command { return ansi.ProgressBar("Deleting action(s)", ids, func(i int, id string) error { if id != "" { - return cli.api.Action.Delete(cmd.Context(), id) + if err := cli.api.Action.Delete(cmd.Context(), id); err != nil { + return fmt.Errorf("failed to delete Action with ID %q: %w", id, err) + } } return nil }) diff --git a/internal/cli/apps.go b/internal/cli/apps.go index 10bd601ca..c60483378 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -350,11 +350,11 @@ func deleteAppCmd(cli *cli) *cobra.Command { return ansi.ProgressBar("Deleting Application(s)", ids, func(_ int, id string) error { if id != "" { if _, err := cli.api.Client.Read(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete application (%s): %w", id, err) + return fmt.Errorf("failed to delete application with ID %q: %w", id, err) } if err := cli.api.Client.Delete(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete application (%s): %w", id, err) + return fmt.Errorf("failed to delete application with ID %q: %w", id, err) } } return nil diff --git a/internal/cli/custom_domains.go b/internal/cli/custom_domains.go index 18ba9cdbe..d21f75b63 100644 --- a/internal/cli/custom_domains.go +++ b/internal/cli/custom_domains.go @@ -350,11 +350,11 @@ func deleteCustomDomainCmd(cli *cli) *cobra.Command { return ansi.ProgressBar("Deleting custom domain", ids, func(_ int, id string) error { if id != "" { if _, err := cli.api.CustomDomain.Read(cmd.Context(), url.PathEscape(id)); err != nil { - return fmt.Errorf("failed to delete custom domain (%s): %w", id, err) + return fmt.Errorf("failed to delete custom domain with ID %q: %w", id, err) } if err := cli.api.CustomDomain.Delete(cmd.Context(), url.PathEscape(id)); err != nil { - return fmt.Errorf("failed to delete custom domain (%s): %w", id, err) + return fmt.Errorf("failed to delete custom domain with ID %q: %w", id, err) } } return nil diff --git a/internal/cli/log_streams.go b/internal/cli/log_streams.go index 769fd1f2c..6fab1292f 100644 --- a/internal/cli/log_streams.go +++ b/internal/cli/log_streams.go @@ -202,10 +202,10 @@ func deleteLogStreamCmd(cli *cli) *cobra.Command { return ansi.ProgressBar("Deleting Log Stream(s)", ids, func(_ int, id string) error { if id != "" { if _, err := cli.api.LogStream.Read(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete log stream (%s): %w", id, err) + return fmt.Errorf("failed to delete log stream with ID %q: %w", id, err) } if err := cli.api.LogStream.Delete(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete log stream (%s): %w", id, err) + return fmt.Errorf("failed to delete log stream with ID %q: %w", id, err) } } return nil diff --git a/internal/cli/organizations.go b/internal/cli/organizations.go index 21a5650e3..163338a1f 100644 --- a/internal/cli/organizations.go +++ b/internal/cli/organizations.go @@ -439,11 +439,11 @@ func deleteOrganizationCmd(cli *cli) *cobra.Command { return ansi.ProgressBar("Deleting organization(s)", ids, func(_ int, id string) error { if _, err := cli.api.Organization.Read(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete organization (%s): %w", id, err) + return fmt.Errorf("failed to delete organization with ID %q: %w", id, err) } if err := cli.api.Organization.Delete(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete organization (%s): %w", id, err) + return fmt.Errorf("failed to delete organization with ID %q: %w", id, err) } return nil }) diff --git a/internal/cli/roles.go b/internal/cli/roles.go index 20583f454..b15c9dbcf 100644 --- a/internal/cli/roles.go +++ b/internal/cli/roles.go @@ -309,11 +309,11 @@ func deleteRoleCmd(cli *cli) *cobra.Command { return ansi.ProgressBar("Deleting Role(s)", ids, func(_ int, id string) error { if id != "" { if _, err := cli.api.Role.Read(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete role (%s): %w", id, err) + return fmt.Errorf("failed to delete role with ID %q: %w", id, err) } if err := cli.api.Role.Delete(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete role (%s): %w", id, err) + return fmt.Errorf("failed to delete role with ID %q: %w", id, err) } } return nil diff --git a/internal/cli/rules.go b/internal/cli/rules.go index 5576c8c7b..046cd91ba 100644 --- a/internal/cli/rules.go +++ b/internal/cli/rules.go @@ -284,11 +284,11 @@ func deleteRuleCmd(cli *cli) *cobra.Command { return ansi.ProgressBar("Deleting Rule(s)", ids, func(_ int, id string) error { if id != "" { if _, err := cli.api.Rule.Read(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete rule (%s): %w", id, err) + return fmt.Errorf("failed to delete rule with ID %q: %w", id, err) } if err := cli.api.Rule.Delete(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete rule (%s): %w", id, err) + return fmt.Errorf("failed to delete rule with ID %q: %w", id, err) } } return nil diff --git a/internal/cli/users.go b/internal/cli/users.go index 4485b00af..a0498e21b 100644 --- a/internal/cli/users.go +++ b/internal/cli/users.go @@ -395,11 +395,11 @@ func deleteUserCmd(cli *cli) *cobra.Command { return ansi.ProgressBar("Deleting user(s)", ids, func(_ int, id string) error { if id != "" { if _, err := cli.api.User.Read(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete user (%s): %w", id, err) + return fmt.Errorf("failed to delete user with ID %q: %w", id, err) } if err := cli.api.User.Delete(cmd.Context(), id); err != nil { - return fmt.Errorf("failed to delete user (%s): %w", id, err) + return fmt.Errorf("failed to delete user with ID %q: %w", id, err) } } return nil