From 30979ec8b36c43aeff6d7fca852a704d815faf4b Mon Sep 17 00:00:00 2001 From: bright-poku Date: Wed, 3 Mar 2021 08:04:10 -0500 Subject: [PATCH 1/4] [CLI-46] updated error messages for apps command --- internal/cli/apps.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/cli/apps.go b/internal/cli/apps.go index 0843b99b0..616ba630e 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -54,7 +54,7 @@ Lists your existing applications. To create one try: }) if err != nil { - return err + return fmt.Errorf("unexpected error occurred: %w", err) } cli.renderer.ApplicationList(list.Clients) @@ -87,10 +87,10 @@ auth0 apps show input := prompt.TextInput(appID, "Id:", "Id of the application.", true) if err := prompt.AskOne(input, &inputs); err != nil { - return err + return fmt.Errorf("an unexpected error occurred: %w", err) } } else { - return errors.New("missing application id") + return errors.New("Please provide an application id") } } else { inputs.ID = args[0] @@ -105,7 +105,7 @@ auth0 apps show }) if err != nil { - return err + return fmt.Errorf("Unable to load application. The ID %w specified doesn't exist", inputs.ID) } revealClientSecret := auth0.StringValue(a.AppType) != "native" && auth0.StringValue(a.AppType) != "spa" @@ -139,10 +139,10 @@ auth0 apps delete input := prompt.TextInput(appID, "Id:", "Id of the application.", true) if err := prompt.AskOne(input, &inputs); err != nil { - return err + return fmt.Errorf("an unexpected error occurred: %w", err) } } else { - return errors.New("missing application id") + return errors.New("Please provide an application id") } } else { inputs.ID = args[0] @@ -190,7 +190,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] true) if err := prompt.AskOne(input, &flags); err != nil { - return err + return fmt.Errorf("an unexpected error occurred: %w", err) } } @@ -206,7 +206,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] true) if err := prompt.AskOne(input, &flags); err != nil { - return err + return fmt.Errorf("an unexpected error occurred: %w", err) } } @@ -214,7 +214,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] input := prompt.TextInput(appDescription, "Description:", "Description of the application.", false) if err := prompt.AskOne(input, &flags); err != nil { - return err + return fmt.Errorf("an unexpected error occurred: %w", err) } } @@ -231,7 +231,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] }) if err != nil { - return err + return fmt.Errorf("unable to create application %w", err) } // note: c is populated with the rest of the client fields by the API during creation. @@ -283,10 +283,10 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] input := prompt.TextInput(appID, "Id:", "Id of the application.", true) if err := prompt.AskOne(input, &inputs); err != nil { - return err + return fmt.Errorf("an unexpected error occurred: %w", err) } } else { - return errors.New("missing application id") + return errors.New("Please provide an application id") } } else { inputs.ID = args[0] @@ -296,7 +296,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] input := prompt.TextInput(appName, "Name:", "Name of the application", true) if err := prompt.AskOne(input, &inputs); err != nil { - return err + return fmt.Errorf("an unexpected error occurred: %w", err) } } @@ -312,7 +312,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] true) if err := prompt.AskOne(input, &inputs); err != nil { - return err + return fmt.Errorf("An unexpected error occurred: %w", err) } } @@ -320,7 +320,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] input := prompt.TextInput(appDescription, "Description:", "Description of the application.", false) if err := prompt.AskOne(input, &inputs); err != nil { - return err + return fmt.Errorf("An unexpected error occurred: %w", err) } } @@ -337,7 +337,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] }) if err != nil { - return err + return fmt.Errorf("unable to update application %v %v", inputs.ID, err) } // note: c is populated with the rest of the client fields by the API during creation. From eb8801a0c3f019eb5b82071b2035b0c223f84e6e Mon Sep 17 00:00:00 2001 From: bright-poku Date: Wed, 3 Mar 2021 08:08:49 -0500 Subject: [PATCH 2/4] [CLI-46] updated error message string format --- internal/cli/apps.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/apps.go b/internal/cli/apps.go index 616ba630e..e2aec0c29 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -105,7 +105,7 @@ auth0 apps show }) if err != nil { - return fmt.Errorf("Unable to load application. The ID %w specified doesn't exist", inputs.ID) + return fmt.Errorf("Unable to load application. The ID %v specified doesn't exist", inputs.ID) } revealClientSecret := auth0.StringValue(a.AppType) != "native" && auth0.StringValue(a.AppType) != "spa" From c6f966f4ccc64e226505783f09ada3a75fd4a90c Mon Sep 17 00:00:00 2001 From: bright-poku Date: Wed, 3 Mar 2021 11:23:37 -0500 Subject: [PATCH 3/4] [CLI-46] capitalize first letter of each error message --- internal/cli/apps.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/cli/apps.go b/internal/cli/apps.go index e2aec0c29..2bcff7392 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -54,7 +54,7 @@ Lists your existing applications. To create one try: }) if err != nil { - return fmt.Errorf("unexpected error occurred: %w", err) + return fmt.Errorf("An unexpected error occurred: %w", err) } cli.renderer.ApplicationList(list.Clients) @@ -87,7 +87,7 @@ auth0 apps show input := prompt.TextInput(appID, "Id:", "Id of the application.", true) if err := prompt.AskOne(input, &inputs); err != nil { - return fmt.Errorf("an unexpected error occurred: %w", err) + return fmt.Errorf("An unexpected error occurred: %w", err) } } else { return errors.New("Please provide an application id") @@ -139,7 +139,7 @@ auth0 apps delete input := prompt.TextInput(appID, "Id:", "Id of the application.", true) if err := prompt.AskOne(input, &inputs); err != nil { - return fmt.Errorf("an unexpected error occurred: %w", err) + return fmt.Errorf("An unexpected error occurred: %w", err) } } else { return errors.New("Please provide an application id") @@ -190,7 +190,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] true) if err := prompt.AskOne(input, &flags); err != nil { - return fmt.Errorf("an unexpected error occurred: %w", err) + return fmt.Errorf("An unexpected error occurred: %w", err) } } @@ -206,7 +206,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] true) if err := prompt.AskOne(input, &flags); err != nil { - return fmt.Errorf("an unexpected error occurred: %w", err) + return fmt.Errorf("An unexpected error occurred: %w", err) } } @@ -214,7 +214,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] input := prompt.TextInput(appDescription, "Description:", "Description of the application.", false) if err := prompt.AskOne(input, &flags); err != nil { - return fmt.Errorf("an unexpected error occurred: %w", err) + return fmt.Errorf("An unexpected error occurred: %w", err) } } @@ -231,7 +231,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] }) if err != nil { - return fmt.Errorf("unable to create application %w", err) + return fmt.Errorf("Unable to create application %w", err) } // note: c is populated with the rest of the client fields by the API during creation. @@ -283,7 +283,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] input := prompt.TextInput(appID, "Id:", "Id of the application.", true) if err := prompt.AskOne(input, &inputs); err != nil { - return fmt.Errorf("an unexpected error occurred: %w", err) + return fmt.Errorf("An unexpected error occurred: %w", err) } } else { return errors.New("Please provide an application id") @@ -296,7 +296,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] input := prompt.TextInput(appName, "Name:", "Name of the application", true) if err := prompt.AskOne(input, &inputs); err != nil { - return fmt.Errorf("an unexpected error occurred: %w", err) + return fmt.Errorf("An unexpected error occurred: %w", err) } } @@ -337,7 +337,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] }) if err != nil { - return fmt.Errorf("unable to update application %v %v", inputs.ID, err) + return fmt.Errorf("Unable to update application %v %v", inputs.ID, err) } // note: c is populated with the rest of the client fields by the API during creation. From 399bb7788c14c5e484f2d7e544107c1976ad8e90 Mon Sep 17 00:00:00 2001 From: bright-poku Date: Wed, 3 Mar 2021 12:05:43 -0500 Subject: [PATCH 4/4] [CLI-46] refactored error message formatting --- internal/cli/apps.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/cli/apps.go b/internal/cli/apps.go index 2bcff7392..93c79001d 100644 --- a/internal/cli/apps.go +++ b/internal/cli/apps.go @@ -105,7 +105,7 @@ auth0 apps show }) if err != nil { - return fmt.Errorf("Unable to load application. The ID %v specified doesn't exist", inputs.ID) + return fmt.Errorf("Unable to load application. The id %v specified doesn't exist", inputs.ID) } revealClientSecret := auth0.StringValue(a.AppType) != "native" && auth0.StringValue(a.AppType) != "spa" @@ -231,7 +231,7 @@ auth0 apps create --name myapp --type [native|spa|regular|m2m] }) if err != nil { - return fmt.Errorf("Unable to create application %w", err) + return fmt.Errorf("Unable to create application: %w", err) } // note: c is populated with the rest of the client fields by the API during creation. @@ -337,7 +337,7 @@ auth0 apps update --name myapp --type [native|spa|regular|m2m] }) if err != nil { - return fmt.Errorf("Unable to update application %v %v", inputs.ID, err) + return fmt.Errorf("Unable to update application %v: %v", inputs.ID, err) } // note: c is populated with the rest of the client fields by the API during creation.