MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / APIStatusError

Class APIStatusError

src/anthropic/_exceptions.py:65–83  ·  view source on GitHub ↗

Raised when an API response has a status code of 4xx or 5xx.

Source from the content-addressed store, hash-verified

63
64
65class APIStatusError(APIError):
66 """Raised when an API response has a status code of 4xx or 5xx."""
67
68 response: httpx.Response
69 status_code: int
70 request_id: str | None
71 type: ErrorType | None
72
73 def __init__(self, message: str, *, response: httpx.Response, body: object | None) -> None:
74 super().__init__(message, response.request, body=body)
75 self.response = response
76 self.status_code = response.status_code
77 self.request_id = response.headers.get("request-id")
78
79 self.type = None
80 if is_dict(body):
81 error = body.get("error")
82 if is_dict(error):
83 self.type = cast(Union[ErrorType, None], error.get("type"))
84
85
86class APIConnectionError(APIError):

Callers 7

_api_status_errorFunction · 0.90
_api_status_errorFunction · 0.90
_make_status_errorMethod · 0.85
_make_status_errorMethod · 0.85
_make_status_errorMethod · 0.85
_make_status_errorMethod · 0.85
_make_status_errorMethod · 0.85

Calls

no outgoing calls

Tested by 2

_api_status_errorFunction · 0.72
_api_status_errorFunction · 0.72