Provide helpers and tests for common error types

Unify error handling in apiserver into a single path - RESTStorage
objects must provide appropriate errors individually.  Ensure ALL
errors which can be traced to logical faults with RESTStorage are
returned as api.Status objects.
This commit is contained in:
Clayton Coleman
2014-07-31 14:26:34 -04:00
parent 71c6e082d4
commit 0083fae453
6 changed files with 202 additions and 113 deletions

View File

@@ -31,6 +31,7 @@ import (
type WatchHandler struct {
storage map[string]RESTStorage
codec Codec
}
func getWatchParams(query url.Values) (label, field labels.Selector, resourceVersion uint64) {
@@ -64,7 +65,7 @@ func (h *WatchHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
label, field, resourceVersion := getWatchParams(req.URL.Query())
watching, err := watcher.Watch(label, field, resourceVersion)
if err != nil {
internalError(err, w)
errorJSON(err, h.codec, w)
return
}