more detailed async error messages (#8164)

This commit is contained in:
serenajiang 2019-09-09 09:09:15 -07:00 committed by Erik Ritter
parent c053e23397
commit 4e2d1c1a62
6 changed files with 12 additions and 8 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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:

View File

@ -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"

View File

@ -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:

View File

@ -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)),
)