Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Wrap check errors with distinct error for scorecard-action to ignore. #2250

Merged
merged 2 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
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))
laurentsimon marked this conversation as resolved.
Show resolved Hide resolved
}
}
return nil
Expand Down
4 changes: 3 additions & 1 deletion errors/public.go
Original file line number Diff line number Diff line change
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