mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #1545 from unihorn/197
etcdhttp: always respond json-format error to client
This commit is contained in:
commit
2235b47030
@ -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…
x
Reference in New Issue
Block a user