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



##########
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:
       Good catch @shwstppr  - I made a boo-boo while refactoring stuff. Just 
fixed it on master.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to