mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-28 22:39:05 +08:00
don't log ERROR in ReportHandler when repo not found in cache
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user