Skip to content

Commit

Permalink
herodot: resolve issue with infinite loop caused by certain error cha…
Browse files Browse the repository at this point in the history
…in (#442)

Closes #441
  • Loading branch information
arekkas committed Apr 30, 2017
1 parent 14ad439 commit e4284f2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion herodot/json.go
Expand Up @@ -62,9 +62,19 @@ func (h *JSON) WriteErrorCode(ctx context.Context, w http.ResponseWriter, r *htt
LogError(err, id, code)
je := ToError(err)
je.StatusCode = code
h.WriteCode(ctx, w, r, je.StatusCode, &jsonError{
js, err := json.Marshal(&jsonError{
RequestID: id,
Error: ToError(err),
Message: err.Error(),
})
if err != nil {
LogError(err, id, http.StatusInternalServerError)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusInternalServerError)
return
}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
w.Write(js)
}

0 comments on commit e4284f2

Please sign in to comment.