aboutsummaryrefslogtreecommitdiffstats
path: root/clients/http/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'clients/http/common.go')
-rw-r--r--clients/http/common.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/clients/http/common.go b/clients/http/common.go
index a0f012e..2a2808c 100644
--- a/clients/http/common.go
+++ b/clients/http/common.go
@@ -3,18 +3,25 @@ package http
import (
"fmt"
"net/http"
+
+ "gopkg.in/src-d/go-git.v2/clients/common"
)
type HTTPError struct {
Response *http.Response
}
-func NewHTTPError(r *http.Response) *HTTPError {
+func NewHTTPError(r *http.Response) error {
if r.StatusCode >= 200 && r.StatusCode < 300 {
return nil
}
- return &HTTPError{r}
+ err := &HTTPError{r}
+ if r.StatusCode == 404 || r.StatusCode == 401 {
+ return common.NewPermanentError(common.NotFoundErr)
+ }
+
+ return common.NewUnexpectedError(err)
}
func (e *HTTPError) StatusCode() int {
@@ -22,7 +29,7 @@ func (e *HTTPError) StatusCode() int {
}
func (e *HTTPError) Error() string {
- return fmt.Sprintf("Error requesting %q status code: %d",
+ return fmt.Sprintf("unexpected requesting %q status code: %d",
e.Response.Request.URL, e.Response.StatusCode,
)
}