betodealmeida commented on a change in pull request #12869:
URL: https://github.com/apache/superset/pull/12869#discussion_r579375296



##########
File path: superset/db_engine_specs/base.py
##########
@@ -177,6 +178,35 @@ class BaseEngineSpec:  # pylint: 
disable=too-many-public-methods
         ),
     }
 
+    @classmethod
+    def get_dbapi_exception_mapping(cls) -> Dict[Type[Exception], 
Type[Exception]]:
+        """
+        Each engine can implement and converge its own specific exceptions into
+        Superset DBAPI exceptions
+
+        Note: On python 3.9 this method can be changed to a classmethod 
property
+        without the need of implementing a metaclass type
+
+        :return: A map of driver specific exception to superset custom 
exceptions
+        """
+        return {}

Review comment:
       @dpgaspar you should be able to build this automatically, since the 
SQLAlchemy dialect exposts the DB API module, which should have the exceptions 
at the top level with standard names.
   
   Something like this (untested):
   
   ```python
   dbapi = cls.get_engine(database).dialect.dbapi()
   
   return {
     getattr(dbapi, name): getattr(superset.exceptions, f"SupersetDBAPI{name}"
     for name in {"ProgrammingError", "DatabaseError", etc}
   }
   ```
   
   Maybe have this as the base method and allow subclasses to define their own?




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