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

Class APIStatusError

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

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