test: add coverage for OpenRouter API error detection

This commit is contained in:
Paul Gauthier (aider) 2025-03-27 06:58:38 -10:00
parent 6e1dd4474b
commit 61705ce7fc

View file

@ -63,3 +63,20 @@ def test_context_window_error():
)
ex_info = ex.get_ex_info(ctx_error)
assert ex_info.retry is False
def test_openrouter_error():
"""Test specific handling of OpenRouter API errors"""
ex = LiteLLMExceptions()
from litellm import APIConnectionError
# Create an APIConnectionError with OpenrouterException message
openrouter_error = APIConnectionError(
message="APIConnectionError: OpenrouterException - 'choices'",
model="openrouter/model",
llm_provider="openrouter"
)
ex_info = ex.get_ex_info(openrouter_error)
assert ex_info.retry is False
assert "OpenRouter API provider is down" in ex_info.description