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

Function ErrorFromHTTPResponseWithMessage

httpgrpc/httpgrpc.go:133–144  ·  view source on GitHub ↗

ErrorFromHTTPResponseWithMessage converts an HTTP response into a grpc error, and uses supplied message for Error message.

(resp *HTTPResponse, msg string)

Source from the content-addressed store, hash-verified

131
132// ErrorFromHTTPResponseWithMessage converts an HTTP response into a grpc error, and uses supplied message for Error message.
133func ErrorFromHTTPResponseWithMessage(resp *HTTPResponse, msg string) error {
134 a, err := types.MarshalAny(resp)
135 if err != nil {
136 return err
137 }
138
139 return status.ErrorProto(&spb.Status{
140 Code: resp.Code,
141 Message: msg,
142 Details: []*types.Any{a},
143 })
144}
145
146// HTTPResponseFromError converts a grpc error into an HTTP response
147func HTTPResponseFromError(err error) (*HTTPResponse, bool) {

Callers 2

HandleMethod · 0.92
ErrorFromHTTPResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected