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



##########
File path: superset/db_engine_specs/base.py
##########
@@ -190,10 +205,27 @@ def get_dbapi_exception_mapping(cls) -> 
Dict[Type[Exception], Type[Exception]]:
 
         :return: A map of driver specific exception to superset custom 
exceptions
         """
-        return {}
+        dbapi_exception_names = {
+            "Error": SupersetDBAPIError,
+            "InterfaceError": SupersetDBAPIInterfaceError,
+            "DatabaseError": SupersetDBAPIDatabaseError,
+            "DataError": SupersetDBAPIDataError,
+            "OperationalError": SupersetDBAPIOperationalError,
+            "IntegrityError": SupersetDBAPIIntegrityError,
+            "InternalError": SupersetDBAPIInternalError,
+            "ProgrammingError": SupersetDBAPIProgrammingError,
+            "NotSupportedError": SupersetDBAPINotSupportedError,
+        }
+        return {
+            getattr(dbapi, exception_name): exception
+            for exception_name, exception in dbapi_exception_names.items()
+            if hasattr(dbapi, exception_name)
+        }

Review comment:
       I think in theory they should be exposed in the main module:
   
   > The module should make all error information available through these 
exceptions or subclasses thereof 
([ref](https://www.python.org/dev/peps/pep-0249/#exceptions))
   
   From the context it seems to me that "module" means the top-level module, 
but if implementations are not following that then it really doesn't matter. :-/
   
   It looks like SQLAlchemy has something similar, let me see how they do it:
   
   
https://github.com/sqlalchemy/sqlalchemy/blob/fcf539d090a95fb179ca03beffd10122e97aa002/lib/sqlalchemy/engine/default.py#L203-L206




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