From 977c2b86572f7197182a45a2a2846a05efd59dcc Mon Sep 17 00:00:00 2001 From: Azeem Shaikh Date: Wed, 11 Aug 2021 11:54:40 -0700 Subject: [PATCH] Log runtime failures in cron job (#840) Co-authored-by: Azeem Shaikh --- cron/worker/main.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cron/worker/main.go b/cron/worker/main.go index e1b63db222c..27684ba77ed 100644 --- a/cron/worker/main.go +++ b/cron/worker/main.go @@ -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 {