diff --git a/handlers/checks.go b/handlers/checks.go index ec2df20..b386d08 100644 --- a/handlers/checks.go +++ b/handlers/checks.go @@ -14,6 +14,14 @@ import ( "github.com/gojp/goreportcard/download" ) +type notFoundError struct { + repo string +} + +func (n notFoundError) Error() string { + return fmt.Sprintf("%q not found in cache", n.repo) +} + func dirName(repo string) string { return fmt.Sprintf("_repos/src/%s", repo) } @@ -34,7 +42,7 @@ func getFromCache(repo string) (checksResp, error) { } cached := b.Get([]byte(repo)) if cached == nil { - return fmt.Errorf("%q not found in cache", repo) + return notFoundError{repo} } err = json.Unmarshal(cached, &resp) diff --git a/handlers/report.go b/handlers/report.go index b9e17fc..272411e 100644 --- a/handlers/report.go +++ b/handlers/report.go @@ -19,7 +19,12 @@ func ReportHandler(w http.ResponseWriter, r *http.Request, repo string, dev bool resp, err := getFromCache(repo) needToLoad := false if err != nil { - log.Println("ERROR ReportHandler:", err) // log error, but continue + switch err.(type) { + case notFoundError: + // don't bother logging - we already log in getFromCache. continue + default: + log.Println("ERROR ReportHandler:", err) // log error, but continue + } needToLoad = true }