villebro 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_r382082901
##########
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(f"Invalid driver {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(f"Invalid URI {e}")
+ return json_error_response(
+ _(
+ "Invalid connnection string, a valid string follows: \n"
+ " 'DRIVER://USER:PASSWORD@DB-HOST/DATABASE-NAME'"
Review comment:
The exact connection string varies from engine to engine. While adding a
valid example to each engine spec might be overkill, it might be good to state
that a valid connection string *usually* follows this pattern.
----------------------------------------------------------------
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]