Module: nagvis
Branch: master
Commit: 8307005017ad243c75b2e9e15c291e2f286058f9
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/nagvis;a=commit;h=8307005017ad243c75b2e9e15c291e2f286058f9

Author: Lars Michelsen <[email protected]>
Date:   Thu Sep 17 15:02:47 2009 +0200

#113 Catch JSON syntax errors from ajax queries

---

 share/frontend/nagvis-js/js/ajax.js |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/share/frontend/nagvis-js/js/ajax.js 
b/share/frontend/nagvis-js/js/ajax.js
index f4b0614..976c0a4 100644
--- a/share/frontend/nagvis-js/js/ajax.js
+++ b/share/frontend/nagvis-js/js/ajax.js
@@ -217,12 +217,25 @@ function getSyncRequest(sUrl, bCacheable, bRetryable) {
                                        
                                        //FIXME: Think about caching the error!
                                } else {
-                                       if(bCacheable) {
+                                       // Handle invalid response (No JSON 
format)
+                                       try {
+                                               sResponse = eval('( 
'+responseText+')');
+                                       } catch(e) {
+                                               var oMsg = {};
+                                               oMsg.type = 'CRITICAL';
+                                               oMsg.message = "Invalid JSON 
response:\n"+responseText;
+                                               oMsg.title = "Syntax error";
+                                               
+                                               // Handle application 
message/error
+                                               frontendMessage(oMsg);
+                                               oMsg = null;
+                                       }
+                                       
+                                       if(sResponse !== null && bCacheable) {
                                                // Cache that answer (only when 
no error/warning/...)
                                                updateQueryCache(url, 
timestamp, responseText);
                                        }
                                        
-                                       sResponse = eval('( '+responseText+')');
                                        responseText = null;
                                }
                        }


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to