fix: error message issue when "exception.body" is None (#5464)

fix errormessage issue when "exception.body" is None

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Feng 2024-12-28 07:48:20 +08:00 committed by GitHub
commit a626209da6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -381,7 +381,7 @@ class ErrorMessage(Message):
exception = exception.__cause__
# Get the error reason
reason = f"**{exception.__class__.__name__}**\n"
if hasattr(exception, "body") and "message" in exception.body:
if hasattr(exception, "body") and isinstance(exception.body, dict) and "message" in exception.body:
reason += f" - **{exception.body.get('message')}**\n"
elif hasattr(exception, "code"):
reason += f" - **Code: {exception.code}**\n"