---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/llm/anthropic_messages/error_translation/functions/translateAnthropicError.md
---

# Function: translateAnthropicError()

```ts
function translateAnthropicError(
  err: unknown,
  retriableStatuses: readonly number[],
  opts?: {
    resolveErrorStatus?: AnthropicMessagesErrorStatusResolver;
    warn?: (msg: string) => void;
  },
): AnthropicErrorClassification;
```

Defined in: [src/batteries/llm/anthropic\_messages/error\_translation.ts:120](https://github.com/NHTIO/ADK/blob/v1.20260803.0/src/src/batteries/llm/anthropic_messages/error_translation.ts#L120)

Classify an error thrown by the Anthropic SDK into an ADK disposition.

## Parameters

| Parameter                  | Type                                                                                                                                                                           | Description                                |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ |
| `err`                      | `unknown`                                                                                                                                                                      | The thrown value.                          |
| `retriableStatuses`        | readonly `number`\[]                                                                                                                                                            | Status codes configured as retriable.      |
| `opts?`                    | { `resolveErrorStatus?`: [`AnthropicMessagesErrorStatusResolver`](../../types/type-aliases/AnthropicMessagesErrorStatusResolver.md); `warn?`: (`msg`: `string`) => `void`; } | Optional status resolver and warning sink. |
| `opts.resolveErrorStatus?` | [`AnthropicMessagesErrorStatusResolver`](../../types/type-aliases/AnthropicMessagesErrorStatusResolver.md)                                                                     | -                                          |
| `opts.warn?`               | (`msg`: `string`) => `void`                                                                                                                                                    | -                                          |

## Returns

[`AnthropicErrorClassification`](../type-aliases/AnthropicErrorClassification.md)

The classification.

## Remarks

Ordering is deliberate. Abort and timeout are checked first because they are control-flow
outcomes rather than failures. `APIConnectionError` is retriable at status `0` — a transport
fault has no HTTP status and never will, and that branch establishes the convention that a
statusless error can still be retriable.

For an `APIError`, the consumer's `resolveErrorStatus` hook (when configured) runs BEFORE both
the context-overflow check and retriable classification, so a recovered status participates in
every downstream decision and is what gets reported — a recovered `529` surfaces as `529`, not
`0`. Without a resolver the behaviour is unchanged from before the hook existed: a statusless
`APIError` coerces to `0`, matches no retriable status, and is fatal.
