Skip to content

Commit

Permalink
feat: allow retrieving the action from an action error
Browse files Browse the repository at this point in the history
When an action error occur within the actions waiter utilities, we are laking information about the related action that failed. With this change, we can now retrieve the action that triggered the failure after casting the error to an action error.
  • Loading branch information
jooola committed Oct 16, 2024
1 parent 65a79f3 commit 4d3bd4d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hcloud/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ const (
type ActionError struct {
Code string
Message string

action *Action
}

// Action returns the [Action] that triggered the error if available.
func (e ActionError) Action() *Action {
return e.action
}

func (e ActionError) Error() string {
Expand All @@ -65,6 +72,7 @@ func (a *Action) Error() error {
return ActionError{
Code: a.ErrorCode,
Message: a.ErrorMessage,
action: a,
}
}
return nil
Expand Down

0 comments on commit 4d3bd4d

Please sign in to comment.