Merge pull request #1601 from aslotnick/1529_presto_error_message

[Presto] Change: better formatted error messages
This commit is contained in:
Arik Fraimovich 2017-02-15 21:40:44 +02:00 committed by GitHub
commit 9c0f0cb044

View File

@ -10,6 +10,7 @@ from collections import defaultdict
try:
from pyhive import presto
from pyhive.exc import DatabaseError
enabled = True
except ImportError:
@ -112,6 +113,11 @@ class Presto(BaseQueryRunner):
data = {'columns': columns, 'rows': rows}
json_data = json.dumps(data, cls=JSONEncoder)
error = None
except DatabaseError, db:
json_data = None
default_message = 'Unspecified DatabaseError: {0}'.format(db.message)
message = db.message.get('failureInfo', {'message', None}).get('message')
error = default_message if message is None else message
except Exception, ex:
json_data = None
error = ex.message