# Preserve typed errors when listing Anthropic models \(\#62791\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/78712609912211332becb84cb7a667d1b7b23f78)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 78712609912211332becb84cb7a667d1b7b23f78

Requested commit: 78712609912211332becb84cb7a667d1b7b23f78

Commit: 78712609912211332becb84cb7a667d1b7b23f78

Tree: ac0cdb9f937b0ffe06d93d52e700acd4e9bdf430

Author: Conrad Irwin

Committer: GitHub

## Message

```
Preserve typed errors when listing Anthropic models (#62791)

Anthropic model-list requests currently flatten request, transport,
response, and API failures into `anyhow` strings. Callers therefore
cannot distinguish an invalid API key from connectivity or provider
failures, even though Anthropic returns a structured error payload.

This changes `list_models` to return `AnthropicError`, maps each request
stage to its existing typed variant, and routes unsuccessful responses
through the same structured response handler used by completion
requests. The language model provider converts that error at its
existing `LanguageModelCompletionError` boundary. A regression test
verifies that an authentication response retains both its error category
and Anthropic's human-readable message.

Testing performed:

- `cargo fmt --check`
- `cargo nextest run -p anthropic -p language_models`
- `./script/clippy -p anthropic -p language_models`

Release Notes:

- Fixed Anthropic API key errors being reported as generic model-list
failures.
```

## Parents

- [83f3a8e3e9324ca68dc64f30e3ecd32d245359dc](https://git.cafe/gitcafe/zed/commit/83f3a8e3e9324ca68dc64f30e3ecd32d245359dc?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/78712609912211332becb84cb7a667d1b7b23f78?format=markdown)
