exception handling in some code blocks

master
Andrew Dolgov 19 years ago
parent d6bf9d4192
commit 7719618b29

@ -1,10 +1,9 @@
function viewfeed(feed, skip, subop, doc) { function viewfeed(feed, skip, subop, doc) {
try {
if (!doc) doc = parent.document; if (!doc) doc = parent.document;
// p_notify("Loading headlines...");
enableHotkeys(); enableHotkeys();
var searchbox = doc.getElementById("searchbox"); var searchbox = doc.getElementById("searchbox");
@ -98,7 +97,9 @@ function viewfeed(feed, skip, subop, doc) {
} */ } */
// notify(""); // notify("");
} catch (e) {
exception_error("viewfeed", e);
}
} }
function localHotkeyHandler(keycode) { function localHotkeyHandler(keycode) {

@ -1,5 +1,10 @@
var hotkeys_enabled = true; var hotkeys_enabled = true;
function exception_error(location, e) {
alert("Exception: " + e.name + "\nMessage: " + e.message +
"\nLocation: " + location);
}
function disableHotkeys() { function disableHotkeys() {
hotkeys_enabled = false; hotkeys_enabled = false;
} }
@ -330,7 +335,7 @@ if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') {
function all_counters_callback() { function all_counters_callback() {
if (xmlhttp_rpc.readyState == 4) { if (xmlhttp_rpc.readyState == 4) {
try {
if (!xmlhttp_rpc.responseXML) { if (!xmlhttp_rpc.responseXML) {
notify("[all_counters_callback] backend did not return valid XML"); notify("[all_counters_callback] backend did not return valid XML");
return; return;
@ -373,6 +378,9 @@ function all_counters_callback() {
} }
} }
} }
} catch (e) {
exception_error("all_counters_callback", e);
}
} }
} }
@ -506,4 +514,3 @@ function getSelectedTableRowIds(content_id, prefix) {
} }

@ -28,8 +28,8 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
} }
function feedlist_callback() { function feedlist_callback() {
var container = document.getElementById('prefContent');
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
var container = document.getElementById('prefContent');
container.innerHTML=xmlhttp.responseText; container.innerHTML=xmlhttp.responseText;
if (active_feed) { if (active_feed) {
var row = document.getElementById("FEEDR-" + active_feed); var row = document.getElementById("FEEDR-" + active_feed);
@ -1146,8 +1146,9 @@ function selectTab(id) {
function init() { function init() {
// IE kludge try {
// IE kludge
if (!xmlhttp) { if (!xmlhttp) {
document.getElementById("prefContent").innerHTML = document.getElementById("prefContent").innerHTML =
"<b>Fatal error:</b> This program needs XmlHttpRequest " + "<b>Fatal error:</b> This program needs XmlHttpRequest " +
@ -1159,32 +1160,11 @@ function init() {
document.onkeydown = hotkey_handler; document.onkeydown = hotkey_handler;
notify(""); notify("");
} catch (e) {
exception_error("init", e);
} }
/*
var help_topic_id = false;
function do_dispOptionHelp() {
if (!xmlhttp_ready(xmlhttp))
return;
xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
param_escape(help_topic_id), true);
xmlhttp.onreadystatechange=gethelp_callback;
xmlhttp.send(null);
} }
function dispOptionHelp(event, sender) {
help_topic_id = sender.id;
// document.setTimeout("do_dispOptionHelp()", 100);
} */
function closeInfoBox() { function closeInfoBox() {
var box = document.getElementById('infoBox'); var box = document.getElementById('infoBox');
var shadow = document.getElementById('infoBoxShadow'); var shadow = document.getElementById('infoBoxShadow');

@ -386,13 +386,10 @@ a.button {
font-weight : bold; font-weight : bold;
} }
.evenSelected { .evenSelected, .oddSelected {
background-color : #e0e0ff; background-color : #e0e0ff;
} }
.oddSelected {
background-color : #e0e0ff;
}
/* /*
.feedUnreadSelected, .feedSelectedUnread, .feedUnreadSelected, .feedSelectedUnread,

@ -62,8 +62,7 @@ function dialog_refresh_callback() {
function refetch_callback() { function refetch_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
try {
// document.title = "Tiny Tiny RSS";
if (!xmlhttp.responseXML) { if (!xmlhttp.responseXML) {
notify("refetch_callback: backend did not return valid XML"); notify("refetch_callback: backend did not return valid XML");
@ -118,7 +117,9 @@ function refetch_callback() {
updateTitle(""); updateTitle("");
notify("All feeds updated."); notify("All feeds updated.");
} catch (e) {
exception_error("refetch_callback", e);
}
} }
} }
@ -126,6 +127,8 @@ function backend_sanity_check_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
try {
if (!xmlhttp.responseXML) { if (!xmlhttp.responseXML) {
fatalError(3); fatalError(3);
return; return;
@ -145,24 +148,12 @@ function backend_sanity_check_callback() {
} }
init_second_stage(); init_second_stage();
}
}
/* wtf this is obsolete } catch (e) {
function updateFeed(feed_id) { exception_error("backend_sanity_check_callback", e);
}
var query_str = "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id;
if (xmlhttp_ready(xmlhttp)) {
xmlhttp.open("GET", query_str, true);
xmlhttp.onreadystatechange=feed_update_callback;
xmlhttp.send(null);
} else {
printLockingError();
} }
} }
*/
function scheduleFeedUpdate(force) { function scheduleFeedUpdate(force) {
@ -343,28 +334,13 @@ function genericSanityCheck() {
fatalError(2); fatalError(2);
} }
/* if (!xmlhttp) {
document.getElementById("headlines").innerHTML =
"<b>Fatal error:</b> This program requires XmlHttpRequest " +
"to function properly. Your browser doesn't seem to support it.";
return false;
}
setCookie("ttrss_vf_test", "TEST");
if (getCookie("ttrss_vf_test") != "TEST") {
document.getElementById("headlines").innerHTML =
"<b>Fatal error:</b> This program requires cookies " +
"to function properly. Your browser doesn't seem to support them.";
return false;
} */
return true; return true;
} }
function init() { function init() {
try {
disableContainerChildren("headlinesToolbar", true); disableContainerChildren("headlinesToolbar", true);
if (!genericSanityCheck()) if (!genericSanityCheck())
@ -374,10 +350,15 @@ function init() {
xmlhttp.onreadystatechange=backend_sanity_check_callback; xmlhttp.onreadystatechange=backend_sanity_check_callback;
xmlhttp.send(null); xmlhttp.send(null);
} catch (e) {
exception_error("init", e);
}
} }
function init_second_stage() { function init_second_stage() {
try {
setCookie("ttrss_vf_actfeed", ""); setCookie("ttrss_vf_actfeed", "");
updateFeedList(false, false); updateFeedList(false, false);
@ -407,7 +388,9 @@ function init_second_stage() {
if (splash) { if (splash) {
splash.style.display = "none"; splash.style.display = "none";
} }
} catch (e) {
exception_error("init_second_stage", e);
}
} }
function quickMenuGo() { function quickMenuGo() {

Loading…
Cancel
Save