Skip to content

Commit

Permalink
Log runtime failures in cron job (#840)
Browse files Browse the repository at this point in the history
Co-authored-by: Azeem Shaikh <azeems@google.com>
  • Loading branch information
azeemshaikh38 and azeemsgoogle committed Aug 11, 2021
1 parent 20370f7 commit 977c2b8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cron/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,17 @@ func processRequest(ctx context.Context,
if err != nil {
return fmt.Errorf("error during RunScorecards: %w", err)
}
if !(*ignoreRuntimeErrors) {
for checkIndex := range result.Checks {
check := &result.Checks[checkIndex]
if errors.As(check.Error2, &sce.ErrScorecardInternal) {
// nolint: errorlint, goerr113
return fmt.Errorf("check %s has a runtime error: %v", check.Name, check.Error2)
}
for checkIndex := range result.Checks {
check := &result.Checks[checkIndex]
if !errors.As(check.Error2, &sce.ErrScorecardInternal) {
continue
}
errorMsg := fmt.Sprintf("check %s has a runtime error: %v", check.Name, check.Error2)
if !(*ignoreRuntimeErrors) {
// nolint: goerr113
return errors.New(errorMsg)
}
log.Print(errorMsg)
}
result.Date = batchRequest.GetJobTime().AsTime().Format("2006-01-02")
if err := result.AsJSON(true /*showDetails*/, zapcore.InfoLevel, &buffer); err != nil {
Expand Down

0 comments on commit 977c2b8

Please sign in to comment.