return custom error response when no .go files are found in the repo, add missing return after 500 error

This commit is contained in:
shawnps
2015-02-08 06:16:17 -08:00
parent d2cf3d3525
commit 03ca936dd9
2 changed files with 4 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ func CheckHandler(w http.ResponseWriter, r *http.Request) {
b, _ := json.Marshal(err)
w.WriteHeader(http.StatusInternalServerError)
w.Write(b)
return
}
b, err := json.Marshal(resp)

View File

@@ -121,6 +121,9 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) {
if err != nil {
return checksResp{}, fmt.Errorf("Could not get filenames: %v", err)
}
if len(filenames) == 0 {
return checksResp{}, fmt.Errorf("No .go files found")
}
checks := []check.Check{check.GoFmt{Dir: dir, Filenames: filenames},
check.GoVet{Dir: dir, Filenames: filenames},
check.GoLint{Dir: dir, Filenames: filenames},