proxy should provide reasonable error when execing on a container which doesn't exist

This commit is contained in:
Paul Bellamy committed 2015-05-19 17:37:23 +01:00
1 parent e6b587ea8d
commit 610bc46970
1 file changed
+11 -8
+11 -8
View File
@@ -27,14 +27,17 @@ func newClient(dial func() (net.Conn, error), i interceptor) *client {
} }
func (c *client) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (c *client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
err := c.InterceptRequest(r) if err := c.InterceptRequest(r); err != nil {
if err == docker.ErrNoSuchImage { _, isNoSuchContainer := err.(*docker.NoSuchContainer)
http.NotFound(w, r) switch {
return case isNoSuchContainer:
} http.Error(w, err.Error(), http.StatusNotFound)
if err != nil { case err == docker.ErrNoSuchImage:
http.Error(w, "Unable to intercept request", http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusNotFound)
Warning.Print("Error intercepting request: ", err) default:
http.Error(w, "Unable to intercept request", http.StatusInternalServerError)
Warning.Print("Error intercepting request: ", err)
}
return return
} }