Skip to content

Commit

Permalink
customize error messages for test command
Browse files Browse the repository at this point in the history
  • Loading branch information
morganelle committed Feb 26, 2021
1 parent d0d5dd2 commit 719698d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/cli/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ Launch a browser to try out your universal login box for the given client.
if clientID == "" {
client, err := getOrCreateCLITesterClient(cli.api.Client)
if err != nil {
return err
return fmt.Errorf("Unable to test the login box; please check your internet connection and verify you haven't reached your apps limit")
}
clientID = client.GetClientID()
}

client, err := cli.api.Client.Read(clientID)
if err != nil {
return err
return fmt.Errorf("Unable to find client %s; if you specified a client, please verify it exists, otherwise re-run the command", clientID)
}

if proceed := runLoginFlowPreflightChecks(cli, client); !proceed {
Expand All @@ -70,7 +70,7 @@ Launch a browser to try out your universal login box for the given client.
cliLoginTestingScopes,
)
if err != nil {
return err
return fmt.Errorf("An unexpected error occurred while logging in to client %s: %e", clientID, err)
}

if err := ansi.Spinner("Fetching user metadata", func() error {
Expand All @@ -79,7 +79,7 @@ Launch a browser to try out your universal login box for the given client.
userInfo, err = authutil.FetchUserInfo(tenant.Domain, tokenResponse.AccessToken)
return err
}); err != nil {
return err
return fmt.Errorf("An unexpected error occurred: %e", err)
}

fmt.Fprint(cli.renderer.MessageWriter, "\n")
Expand Down Expand Up @@ -118,14 +118,14 @@ Fetch an access token for the given client and API.
if clientID == "" {
client, err := getOrCreateCLITesterClient(cli.api.Client)
if err != nil {
return err
return fmt.Errorf("Unable to fetch a token; please check your internet connection and verify you haven't reached your apps limit")
}
clientID = client.GetClientID()
}

client, err := cli.api.Client.Read(clientID)
if err != nil {
return err
return fmt.Errorf("Unable to find client %s; if you specified a client, please verify it exists, otherwise re-run the command", clientID)
}

appType := client.GetAppType()
Expand All @@ -140,7 +140,7 @@ Fetch an access token for the given client and API.
if appType == "non_interactive" {
tokenResponse, err := runClientCredentialsFlow(cli, client, clientID, audience, tenant)
if err != nil {
return err
return fmt.Errorf("An unexpected error occurred while logging in to machine-to-machine client %s: %e", clientID, err)
}

fmt.Fprint(cli.renderer.MessageWriter, "\n")
Expand All @@ -162,7 +162,7 @@ Fetch an access token for the given client and API.
scopes,
)
if err != nil {
return err
return fmt.Errorf("An unexpected error occurred when logging in to client %s: %e", clientID, err)
}

fmt.Fprint(cli.renderer.MessageWriter, "\n")
Expand Down

0 comments on commit 719698d

Please sign in to comment.