You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by GitBox <gi...@apache.org> on 2020/05/08 10:23:45 UTC

[GitHub] [cloudstack-primate] shwstppr commented on a change in pull request #296: view: fix api error handling

shwstppr commented on a change in pull request #296:
URL: https://github.com/apache/cloudstack-primate/pull/296#discussion_r422066423



##########
File path: src/utils/plugins.js
##########
@@ -77,3 +78,35 @@ export const pollJobPlugin = {
   }
 
 }
+
+export const notifierPlugin = {
+
+  install (Vue) {
+    Vue.prototype.$notifyError = function (error) {
+      var msg = 'Request Failed'
+      var desc = ''
+      if (error && error.response) {
+        if (error.response.status) {
+          msg = `Request Failed (${error.response.status})`
+        }
+        if (error.message) {
+          desc = error.message
+        }
+        if (error.response.headers && 'x-description' in error.response.headers) {
+          desc = error.response.headers['x-description']
+        }
+        if (desc === '' && error.response.data) {
+          const responseKey = _.findKey(error.response.data, 'errortext')
+          if (responseKey) {
+            desc = error.response.data[responseKey].errortext
+          }
+        }
+      }
+      notification.error({
+        message: msg,
+        description: error && error.response && 'x-description' in error.response.headers ? error.response.headers['x-description'] : error.message,

Review comment:
       @rhtyd shoud this read, `description: desc`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org