If the error parameter is non-nil, sets the response status code appropriately and writes a CouchDB-style JSON description to the body.
(err error)
| 1668 | // If the error parameter is non-nil, sets the response status code appropriately and |
| 1669 | // writes a CouchDB-style JSON description to the body. |
| 1670 | func (h *handler) writeError(err error) { |
| 1671 | if err != nil { |
| 1672 | status, message := base.ErrorAsHTTPStatus(err) |
| 1673 | h.writeStatus(status, message) |
| 1674 | if status >= 500 { |
| 1675 | if status == http.StatusServiceUnavailable { |
| 1676 | base.InfofCtx(h.ctx(), base.KeyHTTP, "%s: %v", h.formatSerialNumber(), err) |
| 1677 | } else { |
| 1678 | base.ErrorfCtx(h.ctx(), "%s: %v", h.formatSerialNumber(), err) |
| 1679 | } |
| 1680 | } |
| 1681 | } |
| 1682 | } |
| 1683 | |
| 1684 | // Writes the response status code, and if it's an error writes a JSON description to the body. |
| 1685 | func (h *handler) writeStatus(status int, message string) { |
no test coverage detected