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

Function ResponseErrorFromKeyPool

aibridge/intercept/messages/base.go:595–620  ·  view source on GitHub ↗

ResponseErrorFromKeyPool translates a *keypool.Error into a developer-facing ResponseError shaped for the Anthropic API.

(keyPoolErr *keypool.Error)

Source from the content-addressed store, hash-verified

593// ResponseErrorFromKeyPool translates a *keypool.Error into
594// a developer-facing ResponseError shaped for the Anthropic API.
595func ResponseErrorFromKeyPool(keyPoolErr *keypool.Error) *ResponseError {
596 switch keyPoolErr.Kind {
597 case keypool.ErrorKindPermanent:
598 return newResponseError(
599 keyPoolErr.Error(),
600 string(constant.ValueOf[constant.APIError]()),
601 http.StatusBadGateway,
602 keyPoolErr.RetryAfter,
603 )
604 case keypool.ErrorKindRateLimited:
605 return newResponseError(
606 keyPoolErr.Error(),
607 string(constant.ValueOf[constant.RateLimitError]()),
608 http.StatusTooManyRequests,
609 keyPoolErr.RetryAfter,
610 )
611 default:
612 // Fall back to a generic 502.
613 return newResponseError(
614 keyPoolErr.Error(),
615 string(constant.ValueOf[constant.APIError]()),
616 http.StatusBadGateway,
617 keyPoolErr.RetryAfter,
618 )
619 }
620}
621
622func responseErrorFromAPIError(err error) *ResponseError {
623 var apierr *anthropic.Error

Callers 4

KeyFailoverConfigMethod · 0.92
ProcessRequestMethod · 0.70
ProcessRequestMethod · 0.70

Calls 2

newResponseErrorFunction · 0.70
ErrorMethod · 0.45

Tested by 1