Home / File/ _exceptions.py — anthropic-sdk-python Source File

_exceptions.py — anthropic-sdk-python Source File

Architecture documentation for _exceptions.py, a python file in the anthropic-sdk-python codebase. 2 imports, 5 dependents.

File python AnthropicClient SyncAPI 2 imports 5 dependents 18 classes

Entity Profile

Dependency Diagram

graph LR
  b3e43638_c882_dccb_b00e_ddc6b5147130["_exceptions.py"]
  37c05070_ca59_d596_7250_de9d1939227f["typing_extensions"]
  b3e43638_c882_dccb_b00e_ddc6b5147130 --> 37c05070_ca59_d596_7250_de9d1939227f
  9c26e8a9_1ad2_1174_876a_1fc500ce0eaf["httpx"]
  b3e43638_c882_dccb_b00e_ddc6b5147130 --> 9c26e8a9_1ad2_1174_876a_1fc500ce0eaf
  05a7b67e_1fde_5c25_9b37_cc7e827cb62e["__init__.py"]
  05a7b67e_1fde_5c25_9b37_cc7e827cb62e --> b3e43638_c882_dccb_b00e_ddc6b5147130
  31e60ad8_cac8_652d_176d_4f7cf7dda1ad["_base_client.py"]
  31e60ad8_cac8_652d_176d_4f7cf7dda1ad --> b3e43638_c882_dccb_b00e_ddc6b5147130
  3a4e7de9_0222_597c_a697_7ff97bd0dafc["_client.py"]
  3a4e7de9_0222_597c_a697_7ff97bd0dafc --> b3e43638_c882_dccb_b00e_ddc6b5147130
  f3a9224d_bdab_aa4b_9f5e_877302fb10bc["_legacy_response.py"]
  f3a9224d_bdab_aa4b_9f5e_877302fb10bc --> b3e43638_c882_dccb_b00e_ddc6b5147130
  2e9c15bb_de03_aa91_93be_0e05db0a552e["_response.py"]
  2e9c15bb_de03_aa91_93be_0e05db0a552e --> b3e43638_c882_dccb_b00e_ddc6b5147130
  style b3e43638_c882_dccb_b00e_ddc6b5147130 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing_extensions import Literal

import httpx

__all__ = [
    "BadRequestError",
    "AuthenticationError",
    "PermissionDeniedError",
    "NotFoundError",
    "ConflictError",
    "UnprocessableEntityError",
    "RateLimitError",
    "InternalServerError",
]


class AnthropicError(Exception):
    pass


class APIError(AnthropicError):
    message: str
    request: httpx.Request

    body: object | None
    """The API response body.

    If the API responded with a valid JSON structure then this property will be the
    decoded result.

    If it isn't a valid JSON structure then this will be the raw response.

    If there was no response associated with this error then it will be `None`.
    """

    def __init__(self, message: str, request: httpx.Request, *, body: object | None) -> None:  # noqa: ARG002
        super().__init__(message)
        self.request = request
        self.message = message
        self.body = body


class APIResponseValidationError(APIError):
    response: httpx.Response
    status_code: int

    def __init__(self, response: httpx.Response, body: object | None, *, message: str | None = None) -> None:
        super().__init__(message or "Data returned by API invalid for expected schema.", response.request, body=body)
        self.response = response
        self.status_code = response.status_code


class APIStatusError(APIError):
    """Raised when an API response has a status code of 4xx or 5xx."""

    response: httpx.Response
// ... (70 more lines)

Subdomains

Dependencies

  • httpx
  • typing_extensions

Frequently Asked Questions

What does _exceptions.py do?
_exceptions.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What does _exceptions.py depend on?
_exceptions.py imports 2 module(s): httpx, typing_extensions.
What files import _exceptions.py?
_exceptions.py is imported by 5 file(s): __init__.py, _base_client.py, _client.py, _legacy_response.py, _response.py.
Where is _exceptions.py in the architecture?
_exceptions.py is located at src/anthropic/_exceptions.py (domain: AnthropicClient, subdomain: SyncAPI, directory: src/anthropic).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free