Skip to content

Commit

Permalink
Rename error type.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyandrewmeyer committed Feb 4, 2025
1 parent 3a037d6 commit 16f16db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internals/daemon/api_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func v1PostChecks(c *Command, r *http.Request, _ *UserState) Response {
return BadRequest("invalid action %q", payload.Action)
}
if err != nil {
if _, ok := err.(*checkstate.UnknownCheck); ok {
if _, ok := err.(*checkstate.CheckNotFound); ok {
return BadRequest("cannot %s checks: %v", payload.Action, err)
} else {
return InternalError("cannot %s checks: %v", payload.Action, err)
Expand Down
12 changes: 6 additions & 6 deletions internals/overlord/checkstate/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,13 @@ type checker interface {
check(ctx context.Context) error
}

// UnknownCheck is the error returned by StartChecks or StopChecks when a check
// CheckNotFound is the error returned by StartChecks or StopChecks when a check
// with the specified name is not found in the plan.
type UnknownCheck struct {
type CheckNotFound struct {
Name string
}

func (e *UnknownCheck) Error() string {
func (e *CheckNotFound) Error() string {
return fmt.Sprintf("cannot find check %q in plan", e.Name)
}

Expand All @@ -404,7 +404,7 @@ func (m *CheckManager) StartChecks(checks []string) (started []string, err error
// If any check specified is not in the plan, return an error.
for _, name := range checks {
if _, ok := currentPlan.Checks[name]; !ok {
return nil, &UnknownCheck{Name: name}
return nil, &CheckNotFound{Name: name}
}
}

Expand Down Expand Up @@ -443,8 +443,8 @@ func (m *CheckManager) StopChecks(checks []string) (stopped []string, err error)
// If any check specified is not in the plan, return an error.
for _, name := range checks {
if _, ok := currentPlan.Checks[name]; !ok {
return nil, &UnknownCheck{Name: name}
return nil, &UnknownCheck{Name: name}
return nil, &CheckNotFound{Name: name}
return nil, &CheckNotFound{Name: name}
}
}

Expand Down

0 comments on commit 16f16db

Please sign in to comment.