MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / writeError

Method writeError

rest/handler.go:1670–1682  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
1670func (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.
1685func (h *handler) writeStatus(status int, message string) {

Callers 1

makeHandlerWithOptionsFunction · 0.80

Calls 6

writeStatusMethod · 0.95
ctxMethod · 0.95
formatSerialNumberMethod · 0.95
ErrorAsHTTPStatusFunction · 0.92
InfofCtxFunction · 0.92
ErrorfCtxFunction · 0.92

Tested by

no test coverage detected