fix the error code for 400

pull/10616/head
Kelvin Wang 2018-11-02 11:28:39 -04:00
parent 3e54ef9f53
commit cb4e095463
1 changed files with 5 additions and 1 deletions

View File

@ -100,7 +100,11 @@ func EncodeError(ctx context.Context, err error, w http.ResponseWriter) {
}
if pe, ok := err.(*platform.Error); ok {
w.WriteHeader(statusCodePlatformError[platform.ErrorCode(pe)])
httpCode, ok := statusCodePlatformError[platform.ErrorCode(pe)]
if !ok {
httpCode = http.StatusBadRequest
}
w.WriteHeader(httpCode)
b, _ := json.Marshal(pe)
_, _ = w.Write(b)
return