Эх сурвалжийг харах

HUE-4885 [editor] Silently hide the known non support operations from erroring out

Romain Rigaux 9 жил өмнө
parent
commit
b52bb14a2a

+ 3 - 0
desktop/libs/notebook/src/notebook/connectors/base.py

@@ -41,6 +41,9 @@ class AuthenticationRequired(Exception):
 class OperationTimeout(Exception):
   pass
 
+class OperationNotSupported(Exception):
+  pass
+
 
 class QueryError(Exception):
   def __init__(self, message, handle=None):

+ 2 - 2
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -32,7 +32,7 @@ from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import force_unicode
 from desktop.models import DefaultConfiguration
 
-from notebook.connectors.base import Api, QueryError, QueryExpired, OperationTimeout
+from notebook.connectors.base import Api, QueryError, QueryExpired, OperationTimeout, OperationNotSupported
 
 
 LOG = logging.getLogger(__name__)
@@ -301,7 +301,7 @@ class HS2Api(Api):
       raise QueryError(_('Result status is not available'))
 
     if snippet['type'] != 'hive':
-      raise QueryError(_('Cannot fetch result metadata for snippet type: %s') % snippet['type'])
+      raise OperationNotSupported(_('Cannot fetch result metadata for snippet type: %s') % snippet['type'])
 
     engine = self._get_hive_execution_engine(notebook, snippet).lower()
     logs = self.get_log(notebook, snippet, startFrom=0)

+ 5 - 1
desktop/libs/notebook/src/notebook/decorators.py

@@ -28,7 +28,8 @@ from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.i18n import smart_unicode
 from desktop.models import Document2, Document, FilesystemException
 
-from notebook.connectors.base import QueryExpired, QueryError, SessionExpired, AuthenticationRequired, OperationTimeout
+from notebook.connectors.base import QueryExpired, QueryError, SessionExpired, AuthenticationRequired, OperationTimeout,\
+  OperationNotSupported
 
 
 LOG = logging.getLogger(__name__)
@@ -102,6 +103,9 @@ def api_error_handler(func):
         response['handle'] = e.handle
       if e.extra:
         response.update(e.extra)
+    except OperationNotSupported, e:
+      response['status'] = 5
+      response['message'] = e.message
     except Exception, e:
       LOG.exception('Error running %s' % func)
       response['status'] = -1

+ 2 - 0
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -1084,6 +1084,8 @@
       }, function (data) {
         if (data.status == 0) {
           self.result.size(data.result);
+        } else if (data.status == 5) {
+          // No supported yet for this snippet
         } else {
           $(document).trigger("error", data.message);
         }