| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | package apierrorscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/ |
| 4 | |
| 5 | import ( |
| 6 | "fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/" |
| 7 | "net/httpscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/" |
| 8 | "net/http/httputilscip-go gomod github.com/golang/go/src go1.23.0 `net/http/httputil`/" |
| 9 | |
| 10 | "github.com/anthropics/anthropic-sdk-go/internal/apijsonscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apijson`/" |
| 11 | "github.com/anthropics/anthropic-sdk-go/packages/respjsonscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/packages/respjson`/" |
| 12 | ) |
| 13 | |
| 14 | // Error represents an error that originates from the API, i.e. when a request is |
| 15 | // made and the API returns a response with a HTTP status code. Other errors are |
| 16 | // not wrapped by this SDK. |
| 17 | type Errorscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error# struct { |
| 18 | // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. |
| 19 | JSONscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#JSON. struct { |
| 20 | ExtraFieldsscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#$anon_188f484972b699fd#ExtraFields. map[string]respjsonscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/packages/respjson`/.Fieldscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/packages/respjson`/Field# |
| 21 | rawscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#$anon_188f484972b699fd#raw. string |
| 22 | } `json:"-"` |
| 23 | StatusCodescip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#StatusCode. int |
| 24 | Requestscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Request. *httpscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Request# |
| 25 | Responsescip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Response. *httpscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/.Responsescip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Response# |
| 26 | RequestIDscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#RequestID. string |
| 27 | } |
| 28 | |
| 29 | // Returns the unmodified JSON received from the API |
| 30 | func (r Errorscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#) RawJSONscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#RawJSON().() string { return r.JSONscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#JSON..rawscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#$anon_188f484972b699fd#raw. } |
| 31 | func (r *Errorscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#) UnmarshalJSONscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#UnmarshalJSON().(data []byte) error { |
| 32 | return apijsonscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apijson`/.UnmarshalRootscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apijson`/UnmarshalRoot().(data, r) |
| 33 | } |
| 34 | |
| 35 | func (r *Errorscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#) Errorscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Error().() string { |
| 36 | // Attempt to re-populate the response body |
| 37 | statusInfo := fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("%s %q: %d %s", r.Requestscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Request..Methodscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Request#Method., r.Requestscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Request..URLscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Request#URL., r.Responsescip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Response..StatusCodescip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Response#StatusCode., httpscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/.StatusTextscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/StatusText().(r.Responsescip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Response..StatusCodescip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Response#StatusCode.)) |
| 38 | |
| 39 | if r.RequestIDscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#RequestID. != "" { |
| 40 | statusInfo += fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().(" (Request-ID: %s)", r.RequestIDscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#RequestID.) |
| 41 | } |
| 42 | |
| 43 | return fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("%s %s", statusInfo, r.JSONscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#JSON..rawscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#$anon_188f484972b699fd#raw.) |
| 44 | } |
| 45 | |
| 46 | func (r *Errorscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#) DumpRequestscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#DumpRequest().(body bool) []byte { |
| 47 | if r.Requestscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Request..GetBodyscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Request#GetBody. != nil { |
| 48 | r.Requestscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Request..Bodyscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Request#Body., _ = r.Requestscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Request..GetBodyscip-go gomod github.com/golang/go/src go1.23.0 `net/http`/Request#GetBody.() |
| 49 | } |
| 50 | out, _ := httputilscip-go gomod github.com/golang/go/src go1.23.0 `net/http/httputil`/.DumpRequestOutscip-go gomod github.com/golang/go/src go1.23.0 `net/http/httputil`/DumpRequestOut().(r.Requestscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Request., body) |
| 51 | return out |
| 52 | } |
| 53 | |
| 54 | func (r *Errorscip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#) DumpResponsescip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#DumpResponse().(body bool) []byte { |
| 55 | out, _ := httputilscip-go gomod github.com/golang/go/src go1.23.0 `net/http/httputil`/.DumpResponsescip-go gomod github.com/golang/go/src go1.23.0 `net/http/httputil`/DumpResponse().(r.Responsescip-go gomod github.com/anthropics/anthropic-sdk-go . `github.com/anthropics/anthropic-sdk-go/internal/apierror`/Error#Response., body) |
| 56 | return out |
| 57 | } |