From 2732ff5d56f617c2bec9ec85f54fd4e733aebad8 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Fri, 14 Jun 2024 15:08:01 -0700 Subject: [PATCH] fix(utils.py): return traceback on unmapped exception error Fixes https://github.com/BerriAI/litellm/issues/4201 --- litellm/proxy/_experimental/out/404.html | 1 - .../proxy/_experimental/out/model_hub.html | 1 - .../proxy/_experimental/out/onboarding.html | 1 - litellm/utils.py | 19 ++++++++++++++++--- 4 files changed, 16 insertions(+), 6 deletions(-) delete mode 100644 litellm/proxy/_experimental/out/404.html delete mode 100644 litellm/proxy/_experimental/out/model_hub.html delete mode 100644 litellm/proxy/_experimental/out/onboarding.html diff --git a/litellm/proxy/_experimental/out/404.html b/litellm/proxy/_experimental/out/404.html deleted file mode 100644 index f2e61a560d..0000000000 --- a/litellm/proxy/_experimental/out/404.html +++ /dev/null @@ -1 +0,0 @@ -404: This page could not be found.LiteLLM Dashboard

404

This page could not be found.

\ No newline at end of file diff --git a/litellm/proxy/_experimental/out/model_hub.html b/litellm/proxy/_experimental/out/model_hub.html deleted file mode 100644 index 8d95f44aab..0000000000 --- a/litellm/proxy/_experimental/out/model_hub.html +++ /dev/null @@ -1 +0,0 @@ -LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.html deleted file mode 100644 index 7b6369ece0..0000000000 --- a/litellm/proxy/_experimental/out/onboarding.html +++ /dev/null @@ -1 +0,0 @@ -LiteLLM Dashboard \ No newline at end of file diff --git a/litellm/utils.py b/litellm/utils.py index aaf2c1b945..830c45610b 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -8420,7 +8420,7 @@ def exception_type( extra_information = _add_key_name_and_team_to_alert( request_info=extra_information, metadata=_metadata ) - except: + except Exception: # DO NOT LET this Block raising the original exception pass @@ -9956,6 +9956,9 @@ def exception_type( response=original_exception.response, ) else: # ensure generic errors always return APIConnectionError= + """ + For unmapped exceptions - raise the exception with traceback - https://github.com/BerriAI/litellm/issues/4201 + """ exception_mapping_worked = True if hasattr(original_exception, "request"): raise APIConnectionError( @@ -9966,7 +9969,9 @@ def exception_type( ) else: raise APIConnectionError( - message=f"{str(original_exception)}", + message="{}\n{}".format( + str(original_exception), traceback.format_exc() + ), llm_provider=custom_llm_provider, model=model, request=httpx.Request( @@ -9992,7 +9997,15 @@ def exception_type( if exception_mapping_worked: raise e else: - raise original_exception + raise APIConnectionError( + message="{}\n{}".format(original_exception, traceback.format_exc()), + llm_provider="", + model="", + request=httpx.Request( + method="POST", + url="https://www.litellm.ai/", + ), + ) def get_or_generate_uuid():