From 61705ce7fc93ff00fc3562c9d98877822313a7d0 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 27 Mar 2025 06:58:38 -1000 Subject: [PATCH] test: add coverage for OpenRouter API error detection --- tests/basic/test_exceptions.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/basic/test_exceptions.py b/tests/basic/test_exceptions.py index f9262a665..abc33d756 100644 --- a/tests/basic/test_exceptions.py +++ b/tests/basic/test_exceptions.py @@ -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