|
@@ -51,10 +51,17 @@ func parseHTTPErrorResponse(statusCode int, r io.Reader) error {
|
|
|
}
|
|
|
err = json.Unmarshal(body, &detailsErr)
|
|
|
if err == nil && detailsErr.Details != "" {
|
|
|
- if statusCode == http.StatusUnauthorized {
|
|
|
+ switch statusCode {
|
|
|
+ case http.StatusUnauthorized:
|
|
|
return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details)
|
|
|
+ // FIXME: go1.5 doesn't export http.StatusTooManyRequests while
|
|
|
+ // go1.6 does. Update the hardcoded value to the constant once
|
|
|
+ // Docker updates golang version to 1.6.
|
|
|
+ case 429:
|
|
|
+ return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details)
|
|
|
+ default:
|
|
|
+ return errcode.ErrorCodeUnknown.WithMessage(detailsErr.Details)
|
|
|
}
|
|
|
- return errcode.ErrorCodeUnknown.WithMessage(detailsErr.Details)
|
|
|
}
|
|
|
|
|
|
if err := json.Unmarshal(body, &errors); err != nil {
|