Follow Discord
Sweep 24 Nov 2026 · 22:58Z Build v2.1.332 549 read Stable v2.1.326 Latest v2.1.332 Next v2.1.332 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

java changedcli-sdks-libraries/sdks/java

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+12added
Lines−47removed
From line 596 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits46to this page, all time

### Status code mapping

The whole hunk

from line 596, old and new numbered
/
lines
from line 596
596596 
597597## Error handling
598598 
599The SDK throws custom unchecked exception types:
599The SDK throws a subclass of `AnthropicException` when a request fails. Causes include a connection failure and an error response from the API. These exceptions are unchecked. [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.
600600 
601* `AnthropicServiceException` - Base class for HTTP errors
602* `AnthropicIoException` - I/O networking errors
603* `AnthropicRetryableException` - Generic error indicating a failure that could be retried
604* `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)
605* `AnthropicException` - Base class for all exceptions
601Each exception for an error response extends `AnthropicServiceException`. To read the response’s headers, catch that class and call `headers()`. For example, `e.headers().values("retry-after")` returns that header’s values as a list.
606602 
607### Status code mapping
608 
609| Status | Exception |
610| ----- | ----- |
611| 400 | `BadRequestException` |
612| 401 | `UnauthorizedException` |
613| 403 | `PermissionDeniedException` |
614| 404 | `NotFoundException` |
615| 422 | `UnprocessableEntityException` |
616| 429 | `RateLimitException` |
617| 5xx | `InternalServerException` |
618| others | `UnexpectedStatusCodeException` |
619 
620`SseException` is thrown for errors encountered during SSE streaming after a successful initial HTTP response.
621 
622```java
623import com.anthropic.errors.*;
624 
625try {
626 Message message = client.messages().create(params);
627} catch (RateLimitException e) {
628 IO.println("Rate limited, retry after: " + e.headers());
629} catch (UnauthorizedException e) {
630 IO.println("Invalid API key");
631} catch (AnthropicServiceException e) {
632 IO.println("API error: " + e.statusCode());
633} catch (AnthropicIoException e) {
634 IO.println("Network error: " + e.getMessage());
635}
636```
637 
638603## Request IDs
639604 
640605When using [raw responses](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/java#raw-response-access), you can access the `request-id` response header using the `requestId()` method:
from line 617
652617 
653618## Retries
654619 
655The SDK automatically retries 2 times by default, with a short exponential backoff between requests.
620By default, the SDK retries certain errors up to two times (three attempts in all).
656621 
657Only the following error types are retried:
622The SDK retries the following error types:
658623 
659* Connection errors (for example, because of a network connectivity problem)
624* Connection errors and timeouts
660625* 408 Request Timeout
661626* 409 Conflict
662* 429 Rate Limit
663* 5xx Internal
627* 429 Too Many Requests
628* 5xx server errors
664629 
665The API might also explicitly instruct the SDK to retry or not retry a request.
630If 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.
666631 
667632To set a custom number of retries, configure the client using the `maxRetries` method:
668633 
Feedback