Error implements error. If e.Body is a marshalled string of httputil.ErrorJSON, Error returns ErrorJSON.Message . Otherwise Error returns a human-readable string that contains e.StatusCode and e.Body.
()
| 97 | // If e.Body is a marshalled string of httputil.ErrorJSON, Error returns ErrorJSON.Message . |
| 98 | // Otherwise Error returns a human-readable string that contains e.StatusCode and e.Body. |
| 99 | func (e *HTTPStatusError) Error() string { |
| 100 | if e.Body != "" && len(e.Body) < HTTPStatusErrorBodyMaxLength { |
| 101 | var ej httputil.ErrorJSON |
| 102 | if json.Unmarshal([]byte(e.Body), &ej) == nil { |
| 103 | return ej.Message |
| 104 | } |
| 105 | } |
| 106 | return fmt.Sprintf("unexpected HTTP status %s, body=%q", http.StatusText(e.StatusCode), e.Body) |
| 107 | } |
| 108 | |
| 109 | func Successful(resp *http.Response) error { |
| 110 | if resp == nil { |