blob: a0f012ee830bea7da890e0e2698eb864f43868d2 (
plain) (
tree)
|
|
package http
import (
"fmt"
"net/http"
)
type HTTPError struct {
Response *http.Response
}
func NewHTTPError(r *http.Response) *HTTPError {
if r.StatusCode >= 200 && r.StatusCode < 300 {
return nil
}
return &HTTPError{r}
}
func (e *HTTPError) StatusCode() int {
return e.Response.StatusCode
}
func (e *HTTPError) Error() string {
return fmt.Sprintf("Error requesting %q status code: %d",
e.Response.Request.URL, e.Response.StatusCode,
)
}
|