| 1 | package lfshttpscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 6 | |
| 7 | "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/" |
| 8 | "github.com/git-lfs/git-lfs/v3/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/" |
| 9 | ) |
| 10 | |
| 11 | type httpErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/httpError# interface { |
| 12 | Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/httpError#Error.() string |
| 13 | HTTPResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/httpError#HTTPResponse.() *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response# |
| 14 | } |
| 15 | |
| 16 | func IsHTTPscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/IsHTTP().(err error) (*httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#, bool) { |
| 17 | if httpErr, ok := err.(httpErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/httpError#); ok { |
| 18 | return httpErr.HTTPResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/httpError#HTTPResponse.(), true |
| 19 | } |
| 20 | return nil, false |
| 21 | } |
| 22 | |
| 23 | type ClientErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError# struct { |
| 24 | Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#Message. string `json:"message"` |
| 25 | DocumentationUrlscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#DocumentationUrl. string `json:"documentation_url,omitempty"` |
| 26 | RequestIdscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#RequestId. string `json:"request_id,omitempty"` |
| 27 | responsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#response. *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response# |
| 28 | } |
| 29 | |
| 30 | func (e *ClientErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#) HTTPResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#HTTPResponse().() *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response# { |
| 31 | return e.responsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#response. |
| 32 | } |
| 33 | |
| 34 | func (e *ClientErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#) Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#Error().() string { |
| 35 | return e.Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#Message. |
| 36 | } |
| 37 | |
| 38 | func (c *Clientscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Client#) handleResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/Client#handleResponse().(res *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#) error { |
| 39 | if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. < 400 { |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | cliErr := &ClientErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#{responsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#response.: res} |
| 44 | err := DecodeJSONscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/DecodeJSON().(res, cliErr) |
| 45 | if IsDecodeTypeErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/IsDecodeTypeError().(err) { |
| 46 | err = nil |
| 47 | } |
| 48 | |
| 49 | if err == nil { |
| 50 | if len(cliErr.Messagescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/ClientError#Message.) == 0 { |
| 51 | err = defaultErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/defaultError().(res) |
| 52 | } else { |
| 53 | err = cliErr |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. == 401 { |
| 58 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewAuthErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewAuthError().(err) |
| 59 | } |
| 60 | |
| 61 | if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. == 422 { |
| 62 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewUnprocessableEntityErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewUnprocessableEntityError().(err) |
| 63 | } |
| 64 | |
| 65 | if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. == 429 { |
| 66 | // The Retry-After header could be set, check to see if it exists. |
| 67 | h := res.Headerscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Header..Getscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Header#Get().("Retry-After") |
| 68 | retLaterErr := errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableLaterErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableLaterError().(err, h) |
| 69 | if retLaterErr != nil { |
| 70 | return retLaterErr |
| 71 | } |
| 72 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewRetriableErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewRetriableError().(err) |
| 73 | } |
| 74 | |
| 75 | if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. > 499 && res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. != 501 && res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. != 507 && res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. != 509 { |
| 76 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.NewFatalErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/NewFatalError().(err) |
| 77 | } |
| 78 | |
| 79 | return err |
| 80 | } |
| 81 | |
| 82 | type statusCodeErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError# struct { |
| 83 | responsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#response. *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response# |
| 84 | } |
| 85 | |
| 86 | func NewStatusCodeErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/NewStatusCodeError().(res *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#) error { |
| 87 | return &statusCodeErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#{responsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#response.: res} |
| 88 | } |
| 89 | |
| 90 | func (e *statusCodeErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#) Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#Error().() string { |
| 91 | req := e.responsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#response..Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Request. |
| 92 | return trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().( |
| 93 | "Invalid HTTP status for %s %s: %d", |
| 94 | req.Methodscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#Method., |
| 95 | stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.SplitNscip-go gomod github.com/golang/go/src go1.25.0 strings/SplitN().(req.URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL..Stringscip-go gomod github.com/golang/go/src go1.25.0 `net/url`/URL#String().(), "?", 2)[0], |
| 96 | e.responsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#response..StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode., |
| 97 | ) |
| 98 | } |
| 99 | |
| 100 | func (e *statusCodeErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#) HTTPResponsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#HTTPResponse().() *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response# { |
| 101 | return e.responsescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/statusCodeError#response. |
| 102 | } |
| 103 | |
| 104 | func defaultErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfshttp`/defaultError().(res *httpscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#) error { |
| 105 | var msg string |
| 106 | |
| 107 | defaultErrors := map[int]string{ |
| 108 | 400: "Client error: %s", |
| 109 | 401: "Authorization error: %s\nCheck that you have proper access to the repository", |
| 110 | 403: "Authorization error: %s\nCheck that you have proper access to the repository", |
| 111 | 404: "Repository or object not found: %s\nCheck that it exists and that you have proper access to it", |
| 112 | 422: "Unprocessable entity: %s", |
| 113 | 429: "Rate limit exceeded: %s", |
| 114 | 500: "Server error: %s", |
| 115 | 501: "Not Implemented: %s", |
| 116 | 507: "Insufficient server storage: %s", |
| 117 | 509: "Bandwidth limit exceeded: %s", |
| 118 | } |
| 119 | if f, ok := defaultErrors[res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode.]; ok { |
| 120 | msg = trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().(f, res.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Request..URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL.) |
| 121 | } else if res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode. < 500 { |
| 122 | msg = trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("Client error %s from HTTP %d", res.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Request..URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL., res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode.) |
| 123 | } else { |
| 124 | msg = trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("Server error %s from HTTP %d", res.Requestscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#Request..URLscip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Request#URL., res.StatusCodescip-go gomod github.com/golang/go/src go1.25.0 `net/http`/Response#StatusCode.) |
| 125 | } |
| 126 | |
| 127 | return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(msg) |
| 128 | } |