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

Method __init__

src/anthropic/_exceptions.py:125–139  ·  view source on GitHub ↗
(self, message: str, *, response: httpx2.Response, body: object | None)

Source from the content-addressed store, hash-verified

123 """
124
125 def __init__(self, message: str, *, response: httpx2.Response, body: object | None) -> None:
126 # imported here so that modules in `types` can import this one
127 from .types.shared.error_details import ErrorDetails
128
129 super().__init__(message, response.request, body=body)
130 self.response = response
131 self.status_code = response.status_code
132 self.request_id = response.headers.get("request-id")
133 self.workspace_id = response.headers.get("anthropic-workspace-id")
134 self.api_message = extract_property(body, "error", "message")
135 self.type = extract_property(body, "error", "type")
136 self.error_code = extract_error_code(body)
137 self.details = construct_type_or_none(
138 value=extract_property(body, "error", "details"), type_=cast(Any, ErrorDetails)
139 )
140
141
142class APIConnectionError(APIError):

Callers

nothing calls this directly

Calls 5

extract_propertyFunction · 0.85
extract_error_codeFunction · 0.85
construct_type_or_noneFunction · 0.85
__init__Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected