Fix generated JSON in case of error

This commit is contained in:
nemunaire 2017-10-26 14:14:54 +02:00 committed by Pierre-Olivier Mercier
parent ce46313dd1
commit d03350f6b3
3 changed files with 3 additions and 3 deletions

View file

@ -67,7 +67,7 @@ func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, htt
w.WriteHeader(resStatus)
w.Write(bts)
} else if j, err := json.Marshal(ret); err != nil {
http.Error(w, fmt.Sprintf("{\"errmsg\":\"%q\"}", err), http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("{\"errmsg\":%q}", err), http.StatusInternalServerError)
} else {
w.WriteHeader(resStatus)
w.Write(j)