newUploadError captures the status code so the message can name what the endpoint refused.
(err error, a UserAsset)
| 153 | // newUploadError captures the status code so the message can name what the |
| 154 | // endpoint refused. |
| 155 | func newUploadError(err error, a UserAsset) error { |
| 156 | uploadErr := &uploadError{Path: a.Path(), err: err} |
| 157 | if httpError, ok := errors.AsType[api.HTTPError](err); ok { |
| 158 | uploadErr.StatusCode = httpError.StatusCode |
| 159 | uploadErr.Message = httpError.Message |
| 160 | uploadErr.RetryAfter = httpError.Headers.Get("Retry-After") |
| 161 | } |
| 162 | return uploadErr |
| 163 | } |
| 164 | |
| 165 | // uploadError reports a failed upload. StatusCode is zero when the request |
| 166 | // never reached the server. |