[Kimchi-devel] [PATCH 3/4] Pass ajaxError information on to original requester on ajaxError event

Adam King rak at linux.vnet.ibm.com
Thu Feb 27 00:47:40 UTC 2014


The previous implementation on the ajaxError event did not pass along all the
available information to the original caller.  Corrected with this patch.
Updated guest vms processing to use the additional information.
Corrected the error handler to show the JSON response reason when available,
and show the new error message whenever a response is not avail.

Signed-off-by: Adam King <rak at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.guest_main.js | 9 +++++++--
 ui/js/src/kimchi.main.js       | 4 +++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index bbc8051..74bf7ad 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -148,8 +148,13 @@ kimchi.listVmsAuto = function() {
         }
 
         kimchi.vmTimeout = window.setTimeout("kimchi.listVmsAuto();", 5000);
-    }, function(err) {
-        kimchi.message.error(err.responseJSON.reason);
+    }, function(errorResponse, textStatus, errorThrown) {
+        if(errorResponse.responseJSON && errorResponse.responseJSON.reason) {
+            kimchi.message.error(errorResponse.responseJSON.reason);
+        }
+        else {
+            kimchi.message.error(i18n['KCHAPI6007E'].replace("%1", errorResponse.state()));
+        }
         kimchi.vmTimeout = window.setTimeout("kimchi.listVmsAuto();", 5000);
     });
 };
diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
index c9d56e4..6bae95f 100644
--- a/ui/js/src/kimchi.main.js
+++ b/ui/js/src/kimchi.main.js
@@ -163,7 +163,9 @@ kimchi.main = function() {
                 return;
             }
 
-            ajaxSettings['originalError'] && ajaxSettings['originalError'](jqXHR);
+            if(ajaxSettings['originalError']) {
+                jqXHR.fail(ajaxSettings['originalError']);
+            }
         });
 
         kimchi.user.showUser(true);
-- 
1.8.1.4




More information about the Kimchi-devel mailing list