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

Function ErrorFromHTTPResponse

httpgrpc/httpgrpc.go:128–130  ·  view source on GitHub ↗

ErrorFromHTTPResponse converts an HTTP response into a grpc error, and uses HTTP response body as an error message. Note that if HTTP response body contains non-utf8 string, then returned error cannot be marshalled by protobuf.

(resp *HTTPResponse)

Source from the content-addressed store, hash-verified

126// ErrorFromHTTPResponse converts an HTTP response into a grpc error, and uses HTTP response body as an error message.
127// Note that if HTTP response body contains non-utf8 string, then returned error cannot be marshalled by protobuf.
128func ErrorFromHTTPResponse(resp *HTTPResponse) error {
129 return ErrorFromHTTPResponseWithMessage(resp, string(resp.Body))
130}
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 {

Callers 3

HandleMethod · 0.92
ErrorFunction · 0.85

Calls 1

Tested by 1