newUploadError captures the status code so the message can name what the endpoint refused.
(err error, a UserAsset)
| 174 | // newUploadError captures the status code so the message can name what the |
| 175 | // endpoint refused. |
| 176 | func newUploadError(err error, a UserAsset) error { |
| 177 | uploadErr := &uploadError{Path: a.Path(), err: err} |
| 178 | if httpError, ok := errors.AsType[api.HTTPError](err); ok { |
| 179 | uploadErr.StatusCode = httpError.StatusCode |
| 180 | uploadErr.Message = httpError.Message |
| 181 | uploadErr.RetryAfter = httpError.Headers.Get("Retry-After") |
| 182 | } |
| 183 | return uploadErr |
| 184 | } |
| 185 | |
| 186 | // uploadError reports a failed upload. StatusCode is zero when the request |
| 187 | // never reached the server. |