codemaster08240328 commented on code in PR #19672:
URL: https://github.com/apache/superset/pull/19672#discussion_r848853572


##########
superset/views/base.py:
##########
@@ -231,6 +231,9 @@ def wraps(self: "BaseSupersetView", *args: Any, **kwargs: 
Any) -> FlaskResponse:
             return json_error_response(
                 utils.error_msg_from_exception(ex), status=cast(int, ex.code)
             )
+        except (exc.IntegrityError, exc.DatabaseError, exc.DataError) as ex:
+            logger.exception(ex)
+            return json_error_response(utils.error_msg_from_exception(ex), 
status=422)

Review Comment:
   Returning `422` status code for `DatabaseError` and `IntegrityError` is not 
good. Because these errors are not related to the entity which is sent from 
Client side. 
   
   `500` is more acceptable for these errors. 
   `422` is good for `DataError`
   
   Check here:
   https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
   https://docs.sqlalchemy.org/en/14/errors.html



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to