Module: nagvis Branch: nagvis-1.4 Commit: 5355ae1f55aaa432f5ba074d3b5254e78aa3f053 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/nagvis;a=commit;h=5355ae1f55aaa432f5ba074d3b5254e78aa3f053
Author: Lars Michelsen <[email protected]> Date: Thu Sep 17 15:02:47 2009 +0200 #113 Catch JSON syntax errors from ajax queries --- nagvis/nagvis/includes/js/ajax.js | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/nagvis/nagvis/includes/js/ajax.js b/nagvis/nagvis/includes/js/ajax.js index f4b0614..976c0a4 100644 --- a/nagvis/nagvis/includes/js/ajax.js +++ b/nagvis/nagvis/includes/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® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
