csharp changedcli-sdks-libraries/sdks/csharp
Nearest release: v2.1.332, published 6 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+10added
Lines−33removed
From line
138
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits21to this page, all time
The whole hunk
from line 138, old and new numbered
/
from line 138
138138
139139## Error handling
140140
141The SDK throws custom unchecked exception types:
141The SDK throws `AnthropicApiException` when the API returns an error response and `AnthropicIOException` when the SDK can’t connect to the API. These and the SDK’s other exceptions extend `AnthropicException`. [SDK error types](https://platform.claude.com/docs/en/api/errors#sdk-error-types) lists the cases (including errors in a stream), and [Handle errors](https://platform.claude.com/docs/en/api/handle-errors) shows how to catch these exceptions.
142142
143* `AnthropicApiException`: Base class for API errors. See this table for which exception subclass is thrown for each HTTP status code:
144
145| Status | Exception |
146| ----- | ----- |
147| 400 | `AnthropicBadRequestException` |
148| 401 | `AnthropicUnauthorizedException` |
149| 403 | `AnthropicForbiddenException` |
150| 404 | `AnthropicNotFoundException` |
151| 422 | `AnthropicUnprocessableEntityException` |
152| 429 | `AnthropicRateLimitException` |
153| 5xx | `Anthropic5xxException` |
154| others | `AnthropicUnexpectedStatusCodeException` |
155
156Additionally, all 4xx errors inherit from `Anthropic4xxException`.
157
158* `AnthropicSseException`: Errors encountered during SSE streaming after a successful initial HTTP response.
159
160* `AnthropicIOException`: I/O networking errors.
161
162* `AnthropicInvalidDataException`: Failure to interpret successfully parsed data. For example, when accessing a property that’s supposed to be required, but the API unexpectedly omitted it from the response.
163
164* `AnthropicException`: Base class for all exceptions.
165
166143## Retries
167144
168The SDK automatically retries 2 times by default, with a short exponential backoff between requests.
145By default, the SDK retries certain errors up to two times (three attempts in all).
169146
170Only the following error types are retried:
147The SDK retries the following error types:
171148
172* Connection errors (for example, because of a network connectivity problem)
149* Connection errors and timeouts
173150* 408 Request Timeout
174151* 409 Conflict
175* 429 Rate Limit
176* 5xx Internal
152* 429 Too Many Requests
153* 5xx server errors
177154
178The API might also explicitly instruct the SDK to retry or not retry a request.
155If a response has an `x-should-retry` header (`true` or `false`), the SDK follows it instead of the status. Between attempts, the SDK waits as long as the `retry-after` header says, or it uses a short exponential backoff.
179156
180157To set a custom number of retries, configure the client using the `MaxRetries` property:
181158
No line in this hunk matches that.