From 8610bf5afe0cbbdd585a6409b32cff0d70b57332 Mon Sep 17 00:00:00 2001 From: Spencer Schrock Date: Mon, 12 Sep 2022 09:38:56 -0700 Subject: [PATCH] Wrap check errors with distinct error for scorecard-action to ignore. (#2250) Signed-off-by: Spencer Schrock Signed-off-by: Spencer Schrock --- cmd/root.go | 3 ++- errors/public.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 6db0acee1d0c..86711d268900 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,6 +28,7 @@ import ( "github.com/ossf/scorecard/v4/checker" "github.com/ossf/scorecard/v4/clients" docs "github.com/ossf/scorecard/v4/docs/checks" + sce "github.com/ossf/scorecard/v4/errors" sclog "github.com/ossf/scorecard/v4/log" "github.com/ossf/scorecard/v4/options" "github.com/ossf/scorecard/v4/pkg" @@ -162,7 +163,7 @@ func rootCmd(o *options.Options) error { // intentionally placed at end to preserve outputting results, even if a check has a runtime error for _, result := range repoResult.Checks { if result.Error != nil { - return fmt.Errorf("one or more checks had a runtime error: %w", result.Error) + return sce.WithMessage(sce.ErrorCheckRuntime, fmt.Sprintf("%s: %v", result.Name, result.Error)) } } return nil diff --git a/errors/public.go b/errors/public.go index 7ba9f5346813..0bb755c5da5a 100644 --- a/errors/public.go +++ b/errors/public.go @@ -30,8 +30,10 @@ var ( ErrorInvalidURL = errors.New("invalid repo flag") // ErrorShellParsing indicates there was an error when parsing shell code. ErrorShellParsing = errors.New("error parsing shell code") - // ErrorUnsupportedCheck indicates check caanot be run for given request. + // ErrorUnsupportedCheck indicates check cannot be run for given request. ErrorUnsupportedCheck = errors.New("check is not supported for this request") + // ErrorCheckRuntime indicates an individual check had a runtime error. + ErrorCheckRuntime = errors.New("check runtime error") ) // WithMessage wraps any of the errors listed above.