This is an automated email from the ASF dual-hosted git repository. hugh pushed a commit to branch hugh/text-db-config in repository https://gitbox.apache.org/repos/asf/superset.git
commit cf75d8fa6379d6cbc9ec5d0ace702bd36f2622e8 Author: hughhhh <[email protected]> AuthorDate: Wed Apr 14 13:09:54 2021 -0700 move messaging to config --- superset/config.py | 5 +++++ superset/databases/commands/exceptions.py | 5 ++++- superset/databases/commands/test_connection.py | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/superset/config.py b/superset/config.py index e760d7c..c4b0f47 100644 --- a/superset/config.py +++ b/superset/config.py @@ -1179,6 +1179,11 @@ DATASET_HEALTH_CHECK: Optional[Callable[["SqlaTable"], str]] = None SQLALCHEMY_DOCS_URL = "https://docs.sqlalchemy.org/en/13/core/engines.html" SQLALCHEMY_DISPLAY_TEXT = "SQLAlchemy docs" +# Database Connection Config +TEXT_DATABASE_CONNECTION = { + "database_test_connection_unexpected": "Unexpected error occurred, please check your logs for details" +} + # ------------------------------------------------------------------- # * WARNING: STOP EDITING HERE * # ------------------------------------------------------------------- diff --git a/superset/databases/commands/exceptions.py b/superset/databases/commands/exceptions.py index 3205d08..e5e6931 100644 --- a/superset/databases/commands/exceptions.py +++ b/superset/databases/commands/exceptions.py @@ -14,6 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +from flask import current_app from flask_babel import lazy_gettext as _ from marshmallow.validate import ValidationError @@ -27,6 +28,8 @@ from superset.commands.exceptions import ( ) from superset.exceptions import SupersetErrorsException +TEXT_DATABASE_CONN = current_app.config["TEXT_DATABASE_CONNECTION"] + class DatabaseInvalidError(CommandInvalidError): message = _("Database parameters are invalid.") @@ -131,7 +134,7 @@ class DatabaseTestConnectionDriverError(CommandInvalidError): class DatabaseTestConnectionUnexpectedError(CommandInvalidError): - message = _("Unexpected error occurred, please check your logs for details") + message = _(TEXT_DATABASE_CONN["database_test_connection_unexpected"]) class DatabaseImportError(ImportFailedError): diff --git a/superset/databases/commands/test_connection.py b/superset/databases/commands/test_connection.py index 7c2ce6f..f2bf365 100644 --- a/superset/databases/commands/test_connection.py +++ b/superset/databases/commands/test_connection.py @@ -45,6 +45,8 @@ class TestConnectionDatabaseCommand(BaseCommand): def run(self) -> None: self.validate() + + raise DatabaseTestConnectionUnexpectedError() uri = self._properties.get("sqlalchemy_uri", "") if self._model and uri == self._model.safe_sqlalchemy_uri(): uri = self._model.sqlalchemy_uri_decrypted
