]> git.wh0rd.org Git - tt-rss.git/commitdiff
check for backend-returned fatal errors in major callbacks
authorAndrew Dolgov <fox@bah.org.ru>
Sat, 31 Jan 2009 20:03:40 +0000 (23:03 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Sat, 31 Jan 2009 20:03:40 +0000 (23:03 +0300)
feedlist.js
functions.js
viewfeed.js

index 0d45893313de19158d4b492747ec69c6ff9234d7..8f1b5efec2cf5e2e126c6f224b612c32423f56e8 100644 (file)
@@ -33,6 +33,7 @@ function viewCategory(cat) {
 function feedlist_callback2(transport) {
        try {
                debug("feedlist_callback2");
+               if (!transport_error_check(transport)) return;
                var f = document.getElementById("feeds-frame");
                f.innerHTML = transport.responseText;
                feedlist_init();
index e9cbed91b8fb996f3daf046104af8340bb6c74c8..6827420c6b0a2da7bce37a846ff6cc075caaa73f 100644 (file)
@@ -604,24 +604,8 @@ function parse_counters_reply(transport, scheduled_call) {
                updateTitle("");
                return;
        } 
-       
-       var error_code = false;
-       var error_msg = false;
-
-       if (reply.firstChild) {
-               error_code = reply.firstChild.getAttribute("error-code");
-               error_msg = reply.firstChild.getAttribute("error-msg");
-       }
 
-       if (!error_code) {      
-               error_code = reply.getAttribute("error-code");
-               error_msg = reply.getAttribute("error-msg");
-       }
-       
-       if (error_code && error_code != 0) {
-               debug("refetch_callback: got error code " + error_code);
-               return fatalError(error_code, error_msg);
-       }
+       if (!transport_error_check(transport)) return;
 
        var counters = reply.getElementsByTagName("counters")[0];
        
@@ -2104,4 +2088,23 @@ function browseFeeds(limit) {
        }
 }
 
+function transport_error_check(transport) {
+       try {
+               if (transport.responseXML) {
+                       var error = transport.responseXML.getElementsByTagName("error")[0];
+
+                       if (error) {
+                               var code = error.getAttribute("error-code");
+                               var msg = error.getAttribute("error-msg");
+                               if (code != 0) {
+                                       fatalError(code, msg);
+                                       return false;
+                               }
+                       }
+               }
+       } catch (e) {
+               exception_error("check_for_error_xml", e);
+       }
+       return true;
+}
 
index 52f0e8add82a16844b891420e42190ad6809cb87..0f5345b9bfdd44ea16998bfb4f7b3d3c3f47d958 100644 (file)
@@ -67,6 +67,8 @@ function headlines_callback2(transport, feed_cur_page) {
 
                debug("headlines_callback2 [page=" + feed_cur_page + "]");
 
+               if (!transport_error_check(transport)) return;
+
                clean_feed_selections();
        
                var is_cat = false;
@@ -327,6 +329,8 @@ function article_callback2(transport, id, feed_id) {
 
                if (transport.responseXML) {
 
+                       if (!transport_error_check(transport)) return;
+
                        debug("looking for articles to cache...");
 
                        var articles = transport.responseXML.getElementsByTagName("article");