From 71cb19a9929bdd36cfd239f4d6656cdffbf78a50 Mon Sep 17 00:00:00 2001 From: hughhhh Date: Thu, 12 Jan 2023 19:50:53 +0000 Subject: [PATCH] add exc --- .../databases/commands/test_connection.py | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/superset/databases/commands/test_connection.py b/superset/databases/commands/test_connection.py index 37cfd83ced5e3..002adf12368f3 100644 --- a/superset/databases/commands/test_connection.py +++ b/superset/databases/commands/test_connection.py @@ -165,7 +165,9 @@ def ping(engine: Engine) -> bool: except (NoSuchModuleError, ModuleNotFoundError) as ex: event_logger.log_with_context( - action=get_log_connection_action("test_connection_error", ssh_tunnel), + action=get_log_connection_action( + "test_connection_error", ssh_tunnel, ex + ), engine=database.db_engine_spec.__name__, ) raise DatabaseTestConnectionDriverError( @@ -175,7 +177,9 @@ def ping(engine: Engine) -> bool: ) from ex except DBAPIError as ex: event_logger.log_with_context( - action=get_log_connection_action("test_connection_error", ssh_tunnel), + action=get_log_connection_action( + "test_connection_error", ssh_tunnel, ex + ), engine=database.db_engine_spec.__name__, ) # check for custom errors (wrong username, wrong password, etc) @@ -183,21 +187,27 @@ def ping(engine: Engine) -> bool: raise SupersetErrorsException(errors) from ex except SupersetSecurityException as ex: event_logger.log_with_context( - action=get_log_connection_action("test_connection_error", ssh_tunnel), + action=get_log_connection_action( + "test_connection_error", ssh_tunnel, ex + ), engine=database.db_engine_spec.__name__, ) raise DatabaseSecurityUnsafeError(message=str(ex)) from ex except SupersetTimeoutException as ex: event_logger.log_with_context( - action=get_log_connection_action("test_connection_error", ssh_tunnel), + action=get_log_connection_action( + "test_connection_error", ssh_tunnel, ex + ), engine=database.db_engine_spec.__name__, ) # bubble up the exception to return a 408 raise ex except Exception as ex: event_logger.log_with_context( - action=get_log_connection_action("test_connection_error", ssh_tunnel), + action=get_log_connection_action( + "test_connection_error", ssh_tunnel, ex + ), engine=database.db_engine_spec.__name__, ) errors = database.db_engine_spec.extract_errors(ex, context)