Skip to content

Commit

Permalink
update error messages for tenants command
Browse files Browse the repository at this point in the history
  • Loading branch information
morganelle committed Mar 2, 2021
1 parent ac00134 commit db4fd08
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions internal/cli/tenants.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func useTenantCmd(cli *cli) *cobra.Command {
if len(args) == 0 {
tens, err := cli.listTenants()
if err != nil {
return fmt.Errorf("unable to load tenants from config")
return fmt.Errorf("Unable to load tenants due to an unexpected error: %w", err)
}

tenNames := make([]string, len(tens))
Expand All @@ -42,21 +42,20 @@ func useTenantCmd(cli *cli) *cobra.Command {

input := prompt.SelectInput("tenant", "Tenant:", "Tenant to activate", tenNames, true)
if err := prompt.AskOne(input, &selectedTenant); err != nil {
return err
return fmt.Errorf("An unexpected error occurred: %w", err)
}
} else {
requestedTenant := args[0]
t, ok := cli.config.Tenants[requestedTenant]
if !ok {
return fmt.Errorf("Unable to find tenant in config: %s", requestedTenant)

return fmt.Errorf("Unable to find tenant %s; run `auth0 tenants use` to see your configured tenants or run `auth0 login` to configure a new tenant", requestedTenant)
}
selectedTenant = t.Name
}

cli.config.DefaultTenant = selectedTenant
if err := cli.persistConfig(); err != nil {
return fmt.Errorf("persisting config: %w", err)
return fmt.Errorf("An error occurred while setting the default tenant: %w", err)
}
return nil
},
Expand Down

0 comments on commit db4fd08

Please sign in to comment.