浏览代码

HUE-6245 [dataeng] Nicer error when canceling a pending submission

Romain Rigaux 8 年之前
父节点
当前提交
74daa4b97c
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      desktop/libs/notebook/src/notebook/connectors/dataeng.py

+ 7 - 4
desktop/libs/notebook/src/notebook/connectors/dataeng.py

@@ -101,11 +101,14 @@ class DataEngApi(Api):
 
 
   def cancel(self, notebook, snippet):
-    job_id = snippet['result']['handle']['id']
-
-    DataEng(self.user).terminate_jobs(job_ids=[job_id])
+    if snippet['result']['handle'].get('id'):
+      job_id = snippet['result']['handle']['id']
+      DataEng(self.user).terminate_jobs(job_ids=[job_id])
+      response = {'status': 0}
+    else:
+      response = {'status': -1, 'message': _('Could not cancel because of unsuccessful submition.')}
 
-    return {'status': 0}
+    return response
 
 
   def get_log(self, notebook, snippet, startFrom=0, size=None):