Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not pass nil error to error handler #145

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions builder/hcloud/step_create_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu
return errorHandler(state, ui, fmt.Sprintf("Could not fetch SSH key '%s'", k), err)
}
if sshKey == nil {
return errorHandler(state, ui, fmt.Sprintf("Could not find SSH key '%s'", k), err)
return errorHandler(state, ui, "", fmt.Errorf("Could not find SSH key '%s'", k))
}
sshKeys = append(sshKeys, sshKey)
}
Expand Down Expand Up @@ -161,8 +161,7 @@ func (s *stepCreateServer) Cleanup(state multistep.StateBag) {
ui.Say("Destroying server...")
_, _, err := client.Server.DeleteWithResult(context.TODO(), &hcloud.Server{ID: s.serverId})
if err != nil {
ui.Error(fmt.Sprintf(
"Error destroying server. Please destroy it manually: %s", err))
errorHandler(state, ui, "Could not destroy server (please destroy it manually)", err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions builder/hcloud/step_pre_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (s *stepPreValidate) Run(ctx context.Context, state multistep.StateBag) mul
return errorHandler(state, ui, fmt.Sprintf("Could not fetch server type '%s'", c.ServerType), err)
}
if serverType == nil {
return errorHandler(state, ui, fmt.Sprintf("Could not find server type '%s'", c.ServerType), err)
return errorHandler(state, ui, "", fmt.Errorf("Could not find server type '%s'", c.ServerType))
}
state.Put(StateServerType, serverType)

Expand All @@ -39,7 +39,7 @@ func (s *stepPreValidate) Run(ctx context.Context, state multistep.StateBag) mul
return errorHandler(state, ui, fmt.Sprintf("Could not fetch upgrade server type '%s'", c.UpgradeServerType), err)
}
if serverType == nil {
return errorHandler(state, ui, fmt.Sprintf("Could not find upgrade server type '%s'", c.UpgradeServerType), err)
return errorHandler(state, ui, "", fmt.Errorf("Could not find upgrade server type '%s'", c.UpgradeServerType))
}

if serverType.Architecture != upgradeServerType.Architecture {
Expand Down