dpgaspar commented on a change in pull request #9178: [core] Fix, sanitize 
errors returned from testconn
URL: 
https://github.com/apache/incubator-superset/pull/9178#discussion_r382144763
 
 

 ##########
 File path: superset/views/core.py
 ##########
 @@ -1330,11 +1335,32 @@ def testconn(self):
             with closing(engine.connect()) as conn:
                 conn.scalar(select([1]))
                 return json_success('"OK"')
-        except Exception as e:
-            logger.exception(e)
+        except NoSuchModuleError as e:
+            logger.info("Invalid driver %s", e)
+            driver_name = make_url(uri).drivername
             return json_error_response(
-                "Connection failed!\n\n" f"The error message returned 
was:\n{e}", 400
+                _(
+                    "Could not load database driver: %(driver_name)s",
+                    driver_name=driver_name,
+                ),
+                400,
             )
+        except ArgumentError as e:
+            logger.info("Invalid URI %s", e)
+            return json_error_response(
+                _(
+                    "Invalid connection string, a valid string usually 
follows: \n"
+                    "'DRIVER://USER:PASSWORD@DB-HOST/DATABASE-NAME'"
 
 Review comment:
   Will look into that, need to address tests also. This is still draft

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to