This is an automated email from the ASF dual-hosted git repository.

erikrit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e2d1c1  more detailed async error messages (#8164)
4e2d1c1 is described below

commit 4e2d1c1a6205935a8c3d1dfa48a153d5433b314f
Author: serenajiang <serenaji...@berkeley.edu>
AuthorDate: Mon Sep 9 09:09:15 2019 -0700

    more detailed async error messages (#8164)
---
 superset/db_engine_specs/base.py   | 4 ++++
 superset/db_engine_specs/hive.py   | 2 +-
 superset/db_engine_specs/mysql.py  | 2 +-
 superset/db_engine_specs/presto.py | 2 +-
 superset/utils/core.py             | 4 ++--
 tests/db_engine_specs_test.py      | 6 +++---
 6 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index 7df093f..d89f07a 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -473,6 +473,10 @@ class BaseEngineSpec:
 
     @classmethod
     def extract_error_message(cls, e: Exception) -> str:
+        return f"{cls.engine} error: {cls._extract_error_message(e)}"
+
+    @classmethod
+    def _extract_error_message(cls, e: Exception) -> str:
         """Extract error message for queries"""
         return utils.error_msg_from_exception(e)
 
diff --git a/superset/db_engine_specs/hive.py b/superset/db_engine_specs/hive.py
index 5c07e5a..0b765a9 100644
--- a/superset/db_engine_specs/hive.py
+++ b/superset/db_engine_specs/hive.py
@@ -195,7 +195,7 @@ class HiveEngineSpec(PrestoEngineSpec):
         return uri
 
     @classmethod
-    def extract_error_message(cls, e):
+    def _extract_error_message(cls, e):
         msg = str(e)
         match = re.search(r'errorMessage="(.*?)(?<!\\)"', msg)
         if match:
diff --git a/superset/db_engine_specs/mysql.py 
b/superset/db_engine_specs/mysql.py
index a8964a4..467800b 100644
--- a/superset/db_engine_specs/mysql.py
+++ b/superset/db_engine_specs/mysql.py
@@ -86,7 +86,7 @@ class MySQLEngineSpec(BaseEngineSpec):
         return "from_unixtime({col})"
 
     @classmethod
-    def extract_error_message(cls, e):
+    def _extract_error_message(cls, e):
         """Extract error message for queries"""
         message = str(e)
         try:
diff --git a/superset/db_engine_specs/presto.py 
b/superset/db_engine_specs/presto.py
index e648f65..79c7117 100644
--- a/superset/db_engine_specs/presto.py
+++ b/superset/db_engine_specs/presto.py
@@ -863,7 +863,7 @@ class PrestoEngineSpec(BaseEngineSpec):
             polled = cursor.poll()
 
     @classmethod
-    def extract_error_message(cls, e):
+    def _extract_error_message(cls, e):
         if (
             hasattr(e, "orig")
             and type(e.orig).__name__ == "DatabaseError"
diff --git a/superset/utils/core.py b/superset/utils/core.py
index 118d65b..55ada27 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -438,8 +438,8 @@ def error_msg_from_exception(e):
         if isinstance(e.message, dict):
             msg = e.message.get("message")
         elif e.message:
-            msg = "{}".format(e.message)
-    return msg or "{}".format(e)
+            msg = e.message
+    return msg or str(e)
 
 
 def markdown(s: str, markup_wrap: Optional[bool] = False) -> str:
diff --git a/tests/db_engine_specs_test.py b/tests/db_engine_specs_test.py
index 2824205..a6db8a1 100644
--- a/tests/db_engine_specs_test.py
+++ b/tests/db_engine_specs_test.py
@@ -137,7 +137,7 @@ class DbEngineSpecsTestCase(SupersetTestCase):
         )
         self.assertEquals(
             (
-                "Error while compiling statement: FAILED: "
+                "hive error: Error while compiling statement: FAILED: "
                 "SemanticException [Error 10001]: Line 4:5 "
                 "Table not found 'fact_ridesfdslakj'"
             ),
@@ -145,7 +145,7 @@ class DbEngineSpecsTestCase(SupersetTestCase):
         )
 
         e = Exception("Some string that doesn't match the regex")
-        self.assertEquals(str(e), HiveEngineSpec.extract_error_message(e))
+        self.assertEquals(f"hive error: {e}", 
HiveEngineSpec.extract_error_message(e))
 
         msg = (
             "errorCode=10001, "
@@ -153,7 +153,7 @@ class DbEngineSpecsTestCase(SupersetTestCase):
             '=None)"'
         )
         self.assertEquals(
-            ("Error while compiling statement"),
+            ("hive error: Error while compiling statement"),
             HiveEngineSpec.extract_error_message(Exception(msg)),
         )
 

Reply via email to