Browse Source

HUE-1575 [beeswax] expand_exception attribute 'message' fix

Romain: more user friendly exception, just showing up errorMessage
thinker0 12 years ago
parent
commit
943c6ef7c1

+ 3 - 2
apps/beeswax/src/beeswax/server/dbms.py

@@ -77,8 +77,9 @@ def get_query_server_config(name='beeswax'):
 class QueryServerException(Exception):
   # Ideally the query handle will be stored here too.
 
-  def __init__(self, e):
+  def __init__(self, e, message=''):
     super(QueryServerException, self).__init__(e)
+    self.message = message
 
 
 class NoSuchObjectException: pass
@@ -463,7 +464,7 @@ def expand_exception(exc, db, handle=None):
     # Always show something, even if server has died on the job.
     log = _("Could not retrieve logs: %s." % e)
 
-  if not exc.message:
+  if not hasattr(exc, 'message') or not exc.message:
     error_message = _("Unknown exception.")
   else:
     error_message = force_unicode(exc.message, strings_only=True, errors='replace')

+ 5 - 1
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -352,7 +352,11 @@ class HiveServerClient:
 
     if status is not None and res.status.statusCode not in (
         TStatusCode.SUCCESS_STATUS, TStatusCode.SUCCESS_WITH_INFO_STATUS, TStatusCode.STILL_EXECUTING_STATUS):
-      raise QueryServerException(Exception('Bad status for request %s:\n%s' % (req, res)))
+      if hasattr(res.status, 'errorMessage') and res.status.errorMessage:
+        message = res.status.errorMessage
+      else:
+        message = ''
+      raise QueryServerException(Exception('Bad status for request %s:\n%s' % (req, res)), message=message)
     else:
       return res