Report errors
This commit is contained in:
parent
c8d1575ee1
commit
a6a152166e
|
@ -76,6 +76,7 @@ func (a apiRouting) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
if err != nil {
|
||||
ret = map[string]string{"errmsg": err.Error()}
|
||||
resStatus = http.StatusBadRequest
|
||||
log.Println(r.RemoteAddr, resStatus, err.Error())
|
||||
}
|
||||
|
||||
if ret == nil {
|
||||
|
@ -87,7 +88,7 @@ func (a apiRouting) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
w.WriteHeader(resStatus)
|
||||
io.WriteString(w, str)
|
||||
} 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)
|
||||
|
|
Loading…
Reference in New Issue