diff --git a/internal/cli/apis.go b/internal/cli/apis.go index 46d3f788e..ad7b282c1 100644 --- a/internal/cli/apis.go +++ b/internal/cli/apis.go @@ -311,11 +311,13 @@ auth0 apis delete `, } return ansi.Spinner("Deleting API", func() error { - err := cli.api.ResourceServer.Delete(url.PathEscape(inputs.ID)) + _, err := cli.api.ResourceServer.Read(url.PathEscape(inputs.ID)) + if err != nil { - return fmt.Errorf("An unexpected error occurred while attempting to delete an API with Id '%s': %w", inputs.ID, err) + return fmt.Errorf("Unable to delete API. The specified Id: %v doesn't exist", inputs.ID) } - return nil + + return cli.api.ResourceServer.Delete(url.PathEscape(inputs.ID)) }) }, } diff --git a/internal/cli/apps.go b/internal/cli/apps.go index 746e1cde7..412e1d6e0 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -284,7 +284,13 @@ auth0 apps delete `, } } - return ansi.Spinner("Deleting application", func() error { + return ansi.Spinner("Deleting Application", func() error { + _, err := cli.api.Client.Read(inputs.ID) + + if err != nil { + return fmt.Errorf("Unable to delete application. The specified Id: %v doesn't exist", inputs.ID) + } + return cli.api.Client.Delete(inputs.ID) }) }, diff --git a/internal/cli/rules.go b/internal/cli/rules.go index bb8aeaa25..eca48d0a5 100644 --- a/internal/cli/rules.go +++ b/internal/cli/rules.go @@ -244,15 +244,15 @@ auth0 rules delete `, } } - err := ansi.Spinner("Deleting rule", func() error { - return cli.api.Rule.Delete(inputs.ID) - }) + return ansi.Spinner("Deleting Rule", func() error { + _, err := cli.api.Rule.Read(inputs.ID) - if err != nil { - return err - } + if err != nil { + return fmt.Errorf("Unable to delete application. The specified Id: %v doesn't exist", inputs.ID) + } - return nil + return cli.api.Rule.Delete(inputs.ID) + }) }, }