Skip to content

Commit

Permalink
Addressing comments from b. Crochet
Browse files Browse the repository at this point in the history
  • Loading branch information
edcdavid authored and acornett21 committed Jan 24, 2024
1 parent bb672db commit 950b000
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion certification/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Result struct {
// Err contains the error a check itself throws if it failed to run.
// If populated, the expectation is that this Result is in the
// Results{}.Errors slice.
Err error
err error
}

type Results struct {
Expand All @@ -28,3 +28,12 @@ type Results struct {
Errors []Result
Warned []Result
}

func (r Result) Error() error {
return r.err
}

func (r *Result) WithError(err error) *Result {
r.err = err
return r
}
3 changes: 2 additions & 1 deletion internal/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ func (c *craneEngine) ExecuteChecks(ctx context.Context) error {

if err != nil {
logger.WithValues("result", "ERROR", "err", err.Error()).Info("check completed", "check", executedCheck.Name())
c.results.Errors = appendUnlessOptional(c.results.Errors, certification.Result{Check: executedCheck, ElapsedTime: checkElapsedTime, Err: err})
result := certification.Result{Check: executedCheck, ElapsedTime: checkElapsedTime}
c.results.Errors = appendUnlessOptional(c.results.Errors, *result.WithError(err))
continue
}

Expand Down

0 comments on commit 950b000

Please sign in to comment.