MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / FromHTTP

Function FromHTTP

pkg/errors/http.go:103–113  ·  view source on GitHub ↗

FromHTTP reads an error from the HTTP response.

(resp *http.Response)

Source from the content-addressed store, hash-verified

101
102// FromHTTP reads an error from the HTTP response.
103func FromHTTP(resp *http.Response) error {
104 if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
105 return nil
106 }
107 defer resp.Body.Close()
108 var err Error
109 if decErr := json.NewDecoder(resp.Body).Decode(&err); decErr != nil {
110 return decErr
111 }
112 return &err
113}

Callers 2

FileMethod · 0.92
TestHTTPFunction · 0.92

Calls 3

NewDecoderMethod · 0.80
CloseMethod · 0.65
DecodeMethod · 0.65

Tested by 1

TestHTTPFunction · 0.74