etcdhttp: always respond json-format error to client
parent
7f29045c0f
commit
9aefb91531
|
@ -1124,7 +1124,7 @@ func TestBadServeKeys(t *testing.T) {
|
|||
},
|
||||
|
||||
http.StatusInternalServerError,
|
||||
"Internal Server Error",
|
||||
`{"message":"Internal Server Error"}`,
|
||||
},
|
||||
{
|
||||
// etcdserver.Server etcd error
|
||||
|
@ -1144,7 +1144,7 @@ func TestBadServeKeys(t *testing.T) {
|
|||
},
|
||||
|
||||
http.StatusInternalServerError,
|
||||
"Internal Server Error",
|
||||
`{"message":"Internal Server Error"}`,
|
||||
},
|
||||
}
|
||||
for i, tt := range testBadCases {
|
||||
|
|
|
@ -51,7 +51,8 @@ func writeError(w http.ResponseWriter, err error) {
|
|||
e.WriteTo(w)
|
||||
default:
|
||||
log.Printf("etcdhttp: unexpected error: %v", err)
|
||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||
herr := httptypes.NewHTTPError(http.StatusInternalServerError, "Internal Server Error")
|
||||
herr.WriteTo(w)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue