betodealmeida commented on a change in pull request #13244:
URL: https://github.com/apache/superset/pull/13244#discussion_r580493513
##########
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:
For context, SQLAlchemy has a mapping between the exception **name** and
a SQLAlchemy exception, which makes it easier:
https://github.com/sqlalchemy/sqlalchemy/blob/1e75c189da721395bc8c2d899c722a5b9a170404/lib/sqlalchemy/exc.py#L542
----------------------------------------------------------------
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]