Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions litellm/litellm_core_utils/exception_mapping_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,14 @@ def get_error_message(error_obj) -> Optional[str]:
'request_id': 'req_f287898caa6364cd42bc01355f74dd2a'
}
"""
try:
# First, try to access the message directly from the 'body' key
if error_obj is None:
return None
if error_obj is None:
return None

if hasattr(error_obj, "body"):
_error_obj_body = getattr(error_obj, "body")
if isinstance(_error_obj_body, dict):
return _error_obj_body.get("message")
body = getattr(error_obj, "body", None)
if isinstance(body, dict):
return body.get("message")

# If all else fails, return None
return None
except Exception:
return None
return None


####### EXCEPTION MAPPING ################
Expand Down