fix exception handling

This commit is contained in:
ishaan-jaff 2023-09-08 15:42:27 -07:00
parent 599be6a374
commit a9cb373d04

View file

@ -1753,6 +1753,7 @@ def exception_type(model, original_exception, custom_llm_provider):
model=model model=model
) )
else: else:
if hasattr(original_exception, "status_code"):
exception_mapping_worked = True exception_mapping_worked = True
raise APIError( raise APIError(
status_code=original_exception.status_code, status_code=original_exception.status_code,
@ -1927,9 +1928,7 @@ def exception_type(model, original_exception, custom_llm_provider):
litellm.email or "LITELLM_EMAIL" in os.environ litellm.email or "LITELLM_EMAIL" in os.environ
): ):
threading.Thread(target=get_all_keys, args=(e.llm_provider,)).start() threading.Thread(target=get_all_keys, args=(e.llm_provider,)).start()
if exception_mapping_worked: # don't let an error with mapping interrupt the user from receiving an error from the llm api calls
raise e
else: # don't let an error with mapping interrupt the user from receiving an error from the llm api calls
raise original_exception raise original_exception