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

Method Error

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

Source from the content-addressed store, hash-verified

198}
199
200func (e *uploadError) Error() string {
201 switch e.StatusCode {
202 case http.StatusNotFound:
203 // The endpoint answers 404 rather than 403 when the token cannot write,
204 // so the status code alone points at the wrong problem.
205 return fmt.Sprintf("could not upload %s: attaching files requires write access to the repository", e.Path)
206 case http.StatusUnprocessableEntity:
207 if e.Message == "" {
208 return fmt.Sprintf("could not upload %s", e.Path)
209 }
210 return fmt.Sprintf("could not upload %s: %s", e.Path, strings.ReplaceAll(e.Message, "\n", "; "))
211 case http.StatusTooManyRequests:
212 if e.RetryAfter == "" {
213 return fmt.Sprintf("could not upload %s: rate limited; wait and try again", e.Path)
214 }
215 retryAfter := e.RetryAfter
216 if seconds, err := strconv.Atoi(e.RetryAfter); err == nil {
217 retryAfter = fmt.Sprintf("%d seconds", seconds)
218 }
219 return fmt.Sprintf("could not upload %s: rate limited; retry after %s", e.Path, retryAfter)
220 }
221 return fmt.Sprintf("failed to upload %s: %v", e.Path, e.err)
222}
223
224func (e *uploadError) Unwrap() error {
225 return e.err

Calls

no outgoing calls