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

Method markKeyOnError

aibridge/intercept/messages/base.go:579–591  ·  view source on GitHub ↗

For centralized requests, markKeyOnError extracts an Anthropic SDK error from err and marks the key based on its status code. Returns true if the status was a key-specific failover trigger so callers can retry with the next key.

(ctx context.Context, key *keypool.Key, err error)

Source from the content-addressed store, hash-verified

577// its status code. Returns true if the status was a key-specific
578// failover trigger so callers can retry with the next key.
579func (i *interceptionBase) markKeyOnError(ctx context.Context, key *keypool.Key, err error) bool {
580 if i.cfg.KeyPool == nil {
581 return false
582 }
583 var apiErr *anthropic.Error
584 if !errors.As(err, &apiErr) {
585 return false
586 }
587 return keypool.MarkKeyOnStatus(
588 ctx, key, apiErr.Response,
589 i.logger, i.providerName,
590 )
591}
592
593// ResponseErrorFromKeyPool translates a *keypool.Error into
594// a developer-facing ResponseError shaped for the Anthropic API.

Callers 3

TestMarkKeyOnErrorFunction · 0.95
ProcessRequestMethod · 0.45

Calls 2

MarkKeyOnStatusFunction · 0.92
AsMethod · 0.80

Tested by 1

TestMarkKeyOnErrorFunction · 0.76