Skip to content

Commit

Permalink
simplify error check for GetApp, check for nil app to not panic
Browse files Browse the repository at this point in the history
  • Loading branch information
jipperinbham committed Apr 22, 2022
1 parent 29a7c65 commit 25e49d6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/cli/internal/command/machine/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ func runMachineRun(ctx context.Context) error {
}
} else {
app, err = client.GetApp(ctx, appName)
if err != nil && strings.Contains(err.Error(), "Could not resolve App") {
if err != nil && strings.Contains(err.Error(), "Could not resolve") {
app, err = createApp(ctx, fmt.Sprintf("App '%s' does not exist, would you like to create it?", appName), appName, client)
if app == nil {
return nil
}
}
if err != nil {
return err
Expand Down Expand Up @@ -306,7 +309,7 @@ func createApp(ctx context.Context, message, name string, client *api.Client) (*
}

if !confirm {
return nil, err
return nil, nil
}

org, err := prompt.Org(ctx, nil)
Expand Down

0 comments on commit 25e49d6

Please sign in to comment.