MCPcopy Index your code
hub / github.com/coder/coder / responseErrorFromAPIError

Function responseErrorFromAPIError

aibridge/intercept/messages/base.go:622–641  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

620}
621
622func responseErrorFromAPIError(err error) *ResponseError {
623 var apierr *anthropic.Error
624 if !errors.As(err, &apierr) {
625 return nil
626 }
627
628 msg := apierr.Error()
629 errType := string(constant.ValueOf[constant.APIError]())
630
631 var detail *anthropic.APIErrorObject
632 if field, ok := apierr.JSON.ExtraFields["error"]; ok {
633 _ = json.Unmarshal([]byte(field.Raw()), &detail)
634 }
635 if detail != nil {
636 msg = detail.Message
637 errType = string(detail.Type)
638 }
639
640 return newResponseError(msg, errType, apierr.StatusCode, keypool.ParseRetryAfter(apierr.Response))
641}
642
643var _ error = &ResponseError{}
644

Callers 2

mapStreamErrorMethod · 0.85
ProcessRequestMethod · 0.85

Calls 5

ErrorMethod · 0.95
ParseRetryAfterFunction · 0.92
AsMethod · 0.80
newResponseErrorFunction · 0.70
UnmarshalMethod · 0.45

Tested by

no test coverage detected