mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
fix(utils.py): improve coverage for anthropic exception mapping
This commit is contained in:
parent
24addd8a4f
commit
000d678445
2 changed files with 37 additions and 8 deletions
|
@ -5948,7 +5948,6 @@ def exception_type(
|
|||
message=f"AnthropicException - {error_str}",
|
||||
llm_provider="anthropic",
|
||||
model=model,
|
||||
response=original_exception.response,
|
||||
)
|
||||
elif (
|
||||
original_exception.status_code == 400
|
||||
|
@ -5959,7 +5958,13 @@ def exception_type(
|
|||
message=f"AnthropicException - {error_str}",
|
||||
model=model,
|
||||
llm_provider="anthropic",
|
||||
response=original_exception.response,
|
||||
)
|
||||
elif original_exception.status_code == 404:
|
||||
exception_mapping_worked = True
|
||||
raise NotFoundError(
|
||||
message=f"AnthropicException - {error_str}",
|
||||
model=model,
|
||||
llm_provider="anthropic",
|
||||
)
|
||||
elif original_exception.status_code == 408:
|
||||
exception_mapping_worked = True
|
||||
|
@ -5974,16 +5979,20 @@ def exception_type(
|
|||
message=f"AnthropicException - {error_str}",
|
||||
llm_provider="anthropic",
|
||||
model=model,
|
||||
response=original_exception.response,
|
||||
)
|
||||
elif original_exception.status_code == 500:
|
||||
exception_mapping_worked = True
|
||||
raise APIError(
|
||||
status_code=500,
|
||||
message=f"AnthropicException - {error_str}. Handle with `litellm.APIError`.",
|
||||
raise litellm.InternalServerError(
|
||||
message=f"AnthropicException - {error_str}. Handle with `litellm.InternalServerError`.",
|
||||
llm_provider="anthropic",
|
||||
model=model,
|
||||
)
|
||||
elif original_exception.status_code == 503:
|
||||
exception_mapping_worked = True
|
||||
raise litellm.ServiceUnavailableError(
|
||||
message=f"AnthropicException - {error_str}. Handle with `litellm.ServiceUnavailableError`.",
|
||||
llm_provider="anthropic",
|
||||
model=model,
|
||||
request=original_exception.request,
|
||||
)
|
||||
elif custom_llm_provider == "replicate":
|
||||
if "Incorrect authentication token" in error_str:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue