diff --git a/litellm/llms/azure.py b/litellm/llms/azure.py index 8a387e8a9..9c3d04bf1 100644 --- a/litellm/llms/azure.py +++ b/litellm/llms/azure.py @@ -702,7 +702,9 @@ class AzureChatCompletion(BaseLLM): exception_mapping_worked = True raise e except Exception as e: - if exception_mapping_worked: + if hasattr(e, "status_code"): + raise e + elif exception_mapping_worked: raise e else: import traceback diff --git a/litellm/llms/openai.py b/litellm/llms/openai.py index 229d92f6d..ce4cfa596 100644 --- a/litellm/llms/openai.py +++ b/litellm/llms/openai.py @@ -716,12 +716,14 @@ class OpenAIChatCompletion(BaseLLM): exception_mapping_worked = True raise e except Exception as e: - if exception_mapping_worked: + if hasattr(e, "status_code"): + raise e + elif exception_mapping_worked: raise e else: import traceback - raise OpenAIError(status_code=500, message=traceback.format_exc()) + raise AzureOpenAIError(status_code=500, message=traceback.format_exc()) async def ahealth_check( self,