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