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

Class APIStatusError

src/anthropic/_exceptions.py:71–92  ·  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

69
70
71class APIStatusError(APIError):
72 """Raised when an API response has a status code of 4xx or 5xx."""
73
74 response: httpx2.Response
75 status_code: int
76 request_id: str | None
77 type: ErrorType | None
78
79 workspace_id: str | None
80
81 def __init__(self, message: str, *, response: httpx2.Response, body: object | None) -> None:
82 super().__init__(message, response.request, body=body)
83 self.response = response
84 self.status_code = response.status_code
85 self.request_id = response.headers.get("request-id")
86 self.workspace_id = response.headers.get("anthropic-workspace-id")
87
88 self.type = None
89 if is_dict(body):
90 error = body.get("error")
91 if is_dict(error):
92 self.type = cast(Union[ErrorType, None], error.get("type"))
93
94
95class APIConnectionError(APIError):

Callers 9

_api_status_errorFunction · 0.90
_api_status_errorFunction · 0.90
_api_status_errorFunction · 0.90
_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 3

_api_status_errorFunction · 0.72
_api_status_errorFunction · 0.72
_api_status_errorFunction · 0.72