MCPcopy
hub / github.com/grafana/dskit / WriteError

Function WriteError

httpgrpc/httpgrpc.go:81–88  ·  view source on GitHub ↗

WriteError converts an httpgrpc error to an HTTP one

(w http.ResponseWriter, err error)

Source from the content-addressed store, hash-verified

79
80// WriteError converts an httpgrpc error to an HTTP one
81func WriteError(w http.ResponseWriter, err error) {
82 resp, ok := HTTPResponseFromError(err)
83 if ok {
84 _ = WriteResponse(w, resp)
85 } else {
86 http.Error(w, err.Error(), http.StatusInternalServerError)
87 }
88}
89
90func ToHeader(hs []*Header, header http.Header) {
91 for _, h := range hs {

Callers

nothing calls this directly

Calls 3

HTTPResponseFromErrorFunction · 0.85
WriteResponseFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected