Skip to content

Commit

Permalink
Wrap check errors with distinct error for scorecard-action to ignore. (
Browse files Browse the repository at this point in the history
…ossf#2250)

Signed-off-by: Spencer Schrock <sschrock@google.com>

Signed-off-by: Spencer Schrock <sschrock@google.com>
  • Loading branch information
spencerschrock authored and N8BWert committed Sep 23, 2022
1 parent edc243d commit 8610bf5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/root.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion errors/public.go
Expand Up @@ -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.
Expand Down

0 comments on commit 8610bf5

Please sign in to comment.