MCPcopy Index your code
hub / github.com/docker/docker-agent / classifyErrorCode

Function classifyErrorCode

pkg/runtime/loop_steps.go:200–214  ·  view source on GitHub ↗

classifyErrorCode maps a model error to an ErrorCode constant for structured error events. The classification mirrors [modelerrors] but reduces the granularity to a small set of codes that external consumers can act on. Overflow errors are split by [modelerrors.OverflowKind] so the client can rende

(err error)

Source from the content-addressed store, hash-verified

198// can render kind-specific messages (e.g. "request too large" vs "context
199// window exceeded") instead of one generic string.
200func classifyErrorCode(err error) string {
201 switch modelerrors.OverflowKindOf(err) {
202 case modelerrors.OverflowKindWire:
203 return ErrorCodeRequestTooLarge
204 case modelerrors.OverflowKindMedia:
205 return ErrorCodeMediaTooLarge
206 case modelerrors.OverflowKindTokens:
207 return ErrorCodeContextExceeded
208 }
209 _, rateLimited, _ := modelerrors.ClassifyModelError(err)
210 if rateLimited {
211 return ErrorCodeRateLimited
212 }
213 return ErrorCodeModelError
214}

Callers 1

handleStreamErrorMethod · 0.85

Calls 2

OverflowKindOfFunction · 0.92
ClassifyModelErrorFunction · 0.92

Tested by

no test coverage detected