diff --git a/litellm/exceptions.py b/litellm/exceptions.py index 886b5889da0..edc17133d52 100644 --- a/litellm/exceptions.py +++ b/litellm/exceptions.py @@ -337,6 +337,7 @@ class ContextWindowExceededError(BadRequestError): # type: ignore model=self.model, # type: ignore llm_provider=self.llm_provider, # type: ignore response=response, + litellm_debug_info=self.litellm_debug_info, ) # Call the base class constructor with the parameters it needs def __str__(self): @@ -379,6 +380,7 @@ class RejectedRequestError(BadRequestError): # type: ignore model=self.model, # type: ignore llm_provider=self.llm_provider, # type: ignore response=response, + litellm_debug_info=self.litellm_debug_info, ) # Call the base class constructor with the parameters it needs def __str__(self): @@ -418,6 +420,7 @@ class ContentPolicyViolationError(BadRequestError): # type: ignore model=self.model, # type: ignore llm_provider=self.llm_provider, # type: ignore response=response, + litellm_debug_info=self.litellm_debug_info, ) # Call the base class constructor with the parameters it needs def __str__(self): diff --git a/litellm/tests/test_exceptions.py b/litellm/tests/test_exceptions.py index 1082dd2f89f..4d20a39cfdb 100644 --- a/litellm/tests/test_exceptions.py +++ b/litellm/tests/test_exceptions.py @@ -55,8 +55,12 @@ async def test_content_policy_exception_azure(): except litellm.ContentPolicyViolationError as e: print("caught a content policy violation error! Passed") print("exception", e) + assert e.litellm_debug_info is not None + assert isinstance(e.litellm_debug_info, str) + assert len(e.litellm_debug_info) > 0 pass except Exception as e: + print() pytest.fail(f"An exception occurred - {str(e)}")