From b74fa65f6dffb3cc244482dcd3f902419781e9d0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 20 Oct 2011 12:34:22 +0400 Subject: [PATCH] better error logging for invalid JSON data in headlines and article callbacks --- viewfeed.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/viewfeed.js b/viewfeed.js index c5a896aa6..be2c5c67b 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -154,9 +154,10 @@ function headlines_callback2(transport, offset, background) { request_counters(); } else { - console.warn("headlines_callback: returned no XML object"); + console.error("Invalid object received: " + transport.responseText); dijit.byId("headlines-frame").attr('content', "
" + - __('Could not update headlines (invalid object received)') + "
"); + __('Could not update headlines (invalid object received - see error console for details)') + + ""); } _infscroll_request_sent = 0; @@ -246,7 +247,13 @@ function article_callback2(transport, id) { handle_rpc_json(transport); - var reply = JSON.parse(transport.responseText); + var reply = false; + + try { + reply = JSON.parse(transport.responseText); + } catch (e) { + console.error(e); + } if (reply) { @@ -269,10 +276,10 @@ function article_callback2(transport, id) { // } } else { - console.warn("article_callback: returned invalid data"); + console.error("Invalid object received: " + transport.responseText); render_article("
" + - __('Could not display article (invalid data received)') + "
"); + __('Could not display article (invalid object received - see error console for details)') + ""); } request_counters();