| 1 | package putio |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | ) |
| 7 | |
| 8 | // ErrorResponse reports the error caused by an API request. |
| 9 | type ErrorResponse struct { |
| 10 | Response *http.Response `json:"-"` |
| 11 | |
| 12 | Message string `json:"error_message"` |
| 13 | Type string `json:"error_type"` |
| 14 | } |
| 15 | |
| 16 | func (e *ErrorResponse) Error() string { |
| 17 | return fmt.Sprintf( |
| 18 | "Type: %v Message: %q. Original error: %v %v: %v", |
| 19 | e.Type, |
| 20 | e.Message, |
| 21 | e.Response.Request.Method, |
| 22 | e.Response.Request.URL, |
| 23 | e.Response.Status, |
| 24 | ) |
| 25 | } |