betodealmeida commented on code in PR #29780:
URL: https://github.com/apache/superset/pull/29780#discussion_r1697457039


##########
superset/db_engine_specs/base.py:
##########
@@ -92,6 +92,12 @@
 
 logger = logging.getLogger()
 
+# When connecting to a database it's hard to catch specific exceptions, since 
we support
+# more than 50 different database drivers. Usually the try/except block will 
catch the
+# generic `Exception` class, which requires a pylint disablee comment. To make 
it clear
+# that we know this is a necessary evil we create an alias, and catch it 
instead.
+GenericDBException = Exception

Review Comment:
   In that case the exceptions from all the DB API drivers would not be derived 
from `GenericDBException`, so we wouldn't be able to catch them.
   
   The only exception that is a parent to all the exceptions from the multitude 
of DB API drivers we support is `Exception` itself (I hope!), which is why we 
have to write:
   
   ```python
   try:
       # do something with some dynamically loaded DB API driver
   except Exception:  # pylint: disable=broad-except
       pass
   ```
   
   It's inevitable to have a broad except, because the drivers are loaded 
dynamically. My alias is just a way of saying "I know this is bad, but what can 
I do?", but also "I'm excepting an exception here that could be anything".



-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to