Coverage for .venv/lib/python3.13/site-packages/litellm/proxy/client/exceptions.py: 0%
14 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:01 +0000
1import requests
3from litellm.litellm_core_utils.secret_redaction import redact_string
6def _redact_orig_exception(
7 orig_exception: requests.exceptions.HTTPError | str,
8) -> requests.exceptions.HTTPError | str:
9 if isinstance(orig_exception, requests.exceptions.HTTPError):
10 return requests.exceptions.HTTPError(redact_string(str(orig_exception)), response=orig_exception.response)
11 return redact_string(str(orig_exception))
14class UnauthorizedError(Exception):
15 """Exception raised when the API returns a 401 Unauthorized response."""
17 def __init__(self, orig_exception: requests.exceptions.HTTPError | str):
18 self.orig_exception = _redact_orig_exception(orig_exception)
19 super().__init__(str(self.orig_exception))
22class NotFoundError(Exception):
23 """Exception raised when the API returns a 404 Not Found response or indicates a resource was not found."""
25 def __init__(self, orig_exception: requests.exceptions.HTTPError | str):
26 self.orig_exception = _redact_orig_exception(orig_exception)
27 super().__init__(str(self.orig_exception))