fix(utils.py): fix exception_mapping check for errors

If exception already mapped - don't attach traceback to it
This commit is contained in:
Krrish Dholakia 2024-06-24 16:55:19 -07:00
parent 70a605b3cc
commit 123477b55a
2 changed files with 9 additions and 11 deletions

View file

@ -5914,6 +5914,7 @@ def exception_type(
)
else:
# if no status code then it is an APIConnectionError: https://github.com/openai/openai-python#handling-errors
# exception_mapping_worked = True
raise APIConnectionError(
message=f"APIConnectionError: {exception_provider} - {message}",
llm_provider=custom_llm_provider,
@ -7460,6 +7461,9 @@ def exception_type(
if exception_mapping_worked:
raise e
else:
for error_type in litellm.LITELLM_EXCEPTION_TYPES:
if isinstance(e, error_type):
raise e # it's already mapped
raise APIConnectionError(
message="{}\n{}".format(original_exception, traceback.format_exc()),
llm_provider="",