You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "betodealmeida (via GitHub)" <gi...@apache.org> on 2024/07/09 01:06:07 UTC

Re: [PR] fix: refactor view error handling into a separate module [superset]

betodealmeida commented on code in PR #29330:
URL: https://github.com/apache/superset/pull/29330#discussion_r1669494815


##########
superset/utils/core.py:
##########
@@ -432,7 +432,7 @@ def error_msg_from_exception(ex: Exception) -> str:
             msg = ex.message.get("message")  # type: ignore
         elif ex.message:
             msg = ex.message
-    return msg or str(ex)
+    return str(msg) or str(ex)

Review Comment:
   It might be clearer here do to early returns:
   
   ```python
   if message := getattr(ex, "message", None):
       if isinstance(message, dict) and message.get("message"):
           return message["message"]
       return message
   
   return str(ex)
   ```
   
   (I think this is equivalent.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org