ktmud commented on a change in pull request #10274:
URL: 
https://github.com/apache/incubator-superset/pull/10274#discussion_r454122425



##########
File path: superset/exceptions.py
##########
@@ -37,7 +37,19 @@ def exception(self) -> Optional[Exception]:
 
 
 class SupersetTimeoutException(SupersetException):
-    pass
+    status = 408
+
+    def __init__(
+        self,
+        error_type: SupersetErrorType,
+        message: str,
+        level: ErrorLevel,
+        extra: Optional[Dict[str, Any]],
+    ) -> None:
+        super(SupersetTimeoutException, self).__init__(message)
+        self.error = SupersetError(
+            error_type=error_type, message=message, level=level, extra=extra
+        )

Review comment:
       I was thinking maybe subclasses of `SupersetException` itself can handle 
encoding of error code and messages. Here's an example:
   
   ```python
   class SupersetException(Exception, SupersetAlert):
       def __init__(...) -> None:
           SupersetAlert.__init__(
               self, code=code, message=message, description=description, 
extra=extra
           )
           Exception.__init__(self, self.message)
   
   def json_error_response(error: SupersetException) -> FlaskResponse:
      return jsonify({ "error": error.to_json() })
   ```
   
   [Full gist 
here](https://gist.github.com/ktmud/59ccbdf6c96570e1ffe41ee8e5ecd479)




----------------------------------------------------------------
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.

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