MCPcopy Create free account
hub / github.com/cli/cli / Error

Method Error

internal/attachments/client.go:177–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175}
176
177func (e *uploadError) Error() string {
178 switch e.StatusCode {
179 case http.StatusNotFound:
180 // The endpoint answers 404 rather than 403 when the token cannot write,
181 // so the status code alone points at the wrong problem.
182 return fmt.Sprintf("could not upload %s: attaching files requires write access to the repository", e.Path)
183 case http.StatusUnprocessableEntity:
184 if e.Message == "" {
185 return fmt.Sprintf("could not upload %s", e.Path)
186 }
187 return fmt.Sprintf("could not upload %s: %s", e.Path, strings.ReplaceAll(e.Message, "\n", "; "))
188 case http.StatusTooManyRequests:
189 if e.RetryAfter == "" {
190 return fmt.Sprintf("could not upload %s: rate limited; wait and try again", e.Path)
191 }
192 retryAfter := e.RetryAfter
193 if seconds, err := strconv.Atoi(e.RetryAfter); err == nil {
194 retryAfter = fmt.Sprintf("%d seconds", seconds)
195 }
196 return fmt.Sprintf("could not upload %s: rate limited; retry after %s", e.Path, retryAfter)
197 }
198 return fmt.Sprintf("failed to upload %s: %v", e.Path, e.err)
199}
200
201func (e *uploadError) Unwrap() error {
202 return e.err

Calls

no outgoing calls