fix: Improve error logs.

This commit is contained in:
Nicolas Carlier 2014-09-25 09:42:13 +00:00
parent 8e532e2701
commit 6149bca5ab
2 changed files with 5 additions and 3 deletions

View File

@ -18,6 +18,6 @@ func RecordFactory(hookname string) (Record, error) {
case "docker":
return new(DockerRecord), nil
default:
return nil, errors.New("Unknown hookname.")
return nil, errors.New("Unknown hookname: " + hookname)
}
}

View File

@ -96,17 +96,19 @@ func Handler(w http.ResponseWriter, r *http.Request) {
context.Hook = params["hookname"]
context.Action = params["action"]
log.Println("Hook name: ", context.Hook)
var record, err = hook.RecordFactory(context.Hook)
if err != nil {
log.Println(err.Error())
http.Error(w, err.Error(), http.StatusNotFound)
return
}
log.Println("Using hook: ", context.Hook)
decoder := json.NewDecoder(r.Body)
err = decoder.Decode(&record)
if err != nil {
log.Println(err.Error())
http.Error(w, err.Error(), http.StatusBadRequest)
return
}