Skip to content

Commit

Permalink
add exc
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Jan 12, 2023
1 parent 94b711d commit 71cb19a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions superset/databases/commands/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -175,29 +177,37 @@ 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)
errors = database.db_engine_spec.extract_errors(ex, context)
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)
Expand Down

0 comments on commit 71cb19a

Please sign in to comment.