Skip to content

Commit

Permalink
Normalize delete error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Christenson II committed Dec 21, 2023
1 parent d588b4f commit 8f759cf
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
4 changes: 3 additions & 1 deletion internal/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/custom_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/log_streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f759cf

Please sign in to comment.