]> git.wh0rd.org Git - tt-rss.git/commitdiff
new style exception reporting
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 23 Jan 2009 17:19:17 +0000 (18:19 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 23 Jan 2009 17:19:17 +0000 (18:19 +0100)
functions.js
prefs.php
tt-rss.css
tt-rss.js
tt-rss.php
viewfeed.js

index ebf9232e54aa9dfc9943cb3b2989ffb40bd392ab..0e9ec02a162db1642a124f25246274ee4c018aff 100644 (file)
@@ -16,40 +16,41 @@ function is_opera() {
        return window.opera;
 }
 
-function exception_error_ext(location, e, ext_info) {
+function exception_error(location, e, ext_info) {
        var msg = format_exception_error(location, e);
-       var ebc = document.getElementById("xebContent");
 
        disableHotkeys();
 
-       if (ebc) {
-
-               Element.show("dialog_overlay");
-               Element.show("extendedErrorBox");
+       try {
 
-               if (ext_info) {
-                       if (ext_info.responseText) {
-                               ext_info = ext_info.responseText;
+               var ebc = document.getElementById("xebContent");
+       
+               if (ebc) {
+       
+                       Element.show("dialog_overlay");
+                       Element.show("errorBoxShadow");
+       
+                       if (ext_info) {
+                               if (ext_info.responseText) {
+                                       ext_info = ext_info.responseText;
+                               }
                        }
+       
+                       ebc.innerHTML = 
+                               "<div><b>Error message:</b></div>" +
+                               "<pre>" + msg + "</pre>" +
+                               "<div><b>Additional information:</b></div>" +
+                               "<textarea readonly=\"1\">" + ext_info + "</textarea>";
+       
+               } else {
+                       alert(msg);
                }
 
-               ebc.innerHTML = 
-                       "<div><b>Error message:</b></div>" +
-                       "<pre>" + msg + "</pre>" +
-                       "<div><b>Additional information:</b></div>" +
-                       "<textarea readonly=\"1\">" + ext_info + "</textarea>";
-
-       } else {
+       } catch (e) {
                alert(msg);
-       }
-}
-
-function exception_error(location, e, silent) {
-       var msg = format_exception_error(location, e);
 
-       if (!silent) {
-               alert(msg);
        }
+
 }
 
 function format_exception_error(location, e) {
@@ -647,7 +648,7 @@ function all_counters_callback2(transport, async_call) {
                debug("<b>all_counters_callback2 OUT: " + transport + "</b>");
 
        } catch (e) {
-               exception_error("all_counters_callback2", e);
+               exception_error("all_counters_callback2", e, transport);
        }
 }
 
@@ -655,7 +656,6 @@ function get_feed_unread(id) {
        try {
                return parseInt(document.getElementById("FEEDU-" + id).innerHTML);      
        } catch (e) {
-               exception_error("get_feed_unread", e, true);
                return -1;
        }
 }
@@ -667,7 +667,6 @@ function get_cat_unread(id) {
                ctr = ctr.replace(")", "");
                return parseInt(ctr);
        } catch (e) {
-               exception_error("get_feed_unread", e, true);
                return -1;
        }
 }
@@ -1280,10 +1279,9 @@ function leading_zero(p) {
 
 function closeErrorBox() {
 
-       if (Element.visible("extendedErrorBox")) {
+       if (Element.visible("errorBoxShadow")) {
                Element.hide("dialog_overlay");
-       
-               Element.hide("extendedErrorBox");
+               Element.hide("errorBoxShadow");
 
                enableHotkeys();
        }
@@ -1507,7 +1505,7 @@ function storeInitParam(key, value) {
        init_params[key] = value;
 }
 
-function fatalError(code, message) {
+function fatalError(code, msg, ext_info) {
        try {   
 
                if (code == 6) {
@@ -1515,14 +1513,29 @@ function fatalError(code, message) {
                } else if (code == 5) {
                        window.location.href = "update.php";
                } else {
-                       var fe = document.getElementById("fatal_error");
-                       var fc = document.getElementById("fatal_error_msg");
        
-                       if (message == "") message = "Unknown error";
+                       if (msg == "") msg = "Unknown error";
 
-                       fc.innerHTML = "<img src='images/sign_excl.gif'> " + message + " (Code " + code + ")";
+                       var ebc = document.getElementById("xebContent");
        
-                       fe.style.display = "block";
+                       if (ebc) {
+       
+                               Element.show("dialog_overlay");
+                               Element.show("errorBoxShadow");
+                               Element.hide("xebBtn");
+
+                               if (ext_info) {
+                                       if (ext_info.responseText) {
+                                               ext_info = ext_info.responseText;
+                                       }
+                               }
+       
+                               ebc.innerHTML = 
+                                       "<div><b>Error message:</b></div>" +
+                                       "<pre>" + msg + "</pre>" +
+                                       "<div><b>Additional information:</b></div>" +
+                                       "<textarea readonly=\"1\">" + ext_info + "</textarea>";
+                       }
                }
 
        } catch (e) {
index bd29bd8b299cb01dab29afa8e4469a604eee3bb7..7223b3b3ddba396fb7914461ccb8eb53e30755b4 100644 (file)
--- a/prefs.php
+++ b/prefs.php
@@ -78,7 +78,6 @@
        </div>
 </div> 
 
-
 <div id="hotkey_help_overlay" style="display : none" onclick="Element.hide(this)">
        <?php rounded_table_start("hho"); ?>
        <?php include "help/4.php" ?>
@@ -96,11 +95,6 @@ window.onload = init;
 
 <ul id="debug_output" style='display : none'><li>&nbsp;</li></ul>
 
-<div id="fatal_error"><div id="fatal_error_inner">
-       <h1>Fatal Error</h1>
-       <div id="fatal_error_msg"><?php echo __('Unknown Error') ?></div>
-</div></div>
-
 <div id="prefHeader">
        <div class="topLinks">
                <?php if (!SINGLE_USER_MODE) { ?>
@@ -160,6 +154,14 @@ window.onload = init;
 <div id="notify" class="notify"><span id="notify_body">&nbsp;</span></div>
 <div id="infoBoxShadow"><div id="infoBox">BAH</div></div>
 
+<div id="errorBoxShadow" style="display : none">
+       <div id="errorBox">
+               <div id="xebTitle">Fatal Exception</div><div id="xebContent">&nbsp;</div>
+               <div id="xebBtn" align='center'><input type="submit" 
+                       onclick="closeErrorBox()" value="Close this window"/></div>
+       </div>
+</div>
+
 <div id="dialog_overlay" style="display : none"> </div>
 
 <div id="prefFooter">
index 96502b5603763011d3cbd8ae5a6be589529bc8b9..ddeb44f5434ad5923c6025d527087ce2eadfb0c9 100644 (file)
@@ -567,13 +567,25 @@ div.helpResponse {
        top : -4px;
 }
 
-html>body #infoBox {
+div#errorBox {
+       background-color : #ffcccc;
+       border : 1px solid #ff0000;
+       font-size : 12px;
+       position: relative;
+       overflow : hidden;
+       left : -4px;
+       top : -4px;
+}
+
+
+html>body #infoBox, html>body #errorBox {
        left : -10px;
        top : -10px;
        margin : 0;
 }
 
-#infoBoxShadow:before, #infoBoxShadow:after {
+#infoBoxShadow:before, #infoBoxShadow:after, 
+#errorBoxShadow:before, #errorBoxShadow:after {
        content : " ";
        display : block;
        background : inherit;
@@ -581,7 +593,7 @@ html>body #infoBox {
        height : 10px;
 }
 
-#infoBoxShadow:before {
+#infoBoxShadow:before, #errorBoxShadow:before {
        position : absolute;
        top : 0;
        right : 0;
@@ -589,24 +601,30 @@ html>body #infoBox {
        background-position : right top;
 }
 
-#infoBoxShadow:after {
+#infoBoxShadow:after, #errorBoxShadow:after {
        margin : -10px 0 0 -10px;
        background-position : left bottom;
 }
 
 
-#infoBoxShadow {
+#infoBoxShadow, #errorBoxShadow {
        background-image : url("images/shadow.png");
        background-position : bottom right;
        left : 25%;
        top : 70px;
        width : 50%;
-       z-index : 5;
        position : absolute;
-       display : none;
        min-width : 600px;
 } 
 
+#infoBoxShadow {
+       z-index : 5;
+}
+
+#errorBoxShadow {
+       z-index : 400;
+}
+
 div.infoBoxContents {
        padding : 10px;
        margin-bottom : 5px;
@@ -1328,44 +1346,6 @@ a.cdmToggleLink:hover {
        margin : 10px;
 }
 
-#fatal_error {
-       background : white;
-       left : 0;
-       top : 0;
-       height : 100%;
-       width : 100%;
-       z-index : 200;
-       display : none;
-       position : absolute;
-}
-
-#fatal_error_inner {
-       font-weight : bold;
-       margin : 10px;
-       color : red;
-}
-
-#fatal_error_msg {
-       color : black;
-       padding : 10px;
-       font-weight : normal;
-       background-color : #ffcccc;
-       border : 1px solid #ff0000;
-}
-
-#fatal_error_msg a {
-       color : red;
-}
-
-#fatal_error_msg a:hover {
-       color : red;
-       text-decoration : underline;
-}
-
-#fatal_error_msg img {
-       vertical-align : middle;
-}
-
 #noDaemonWarning {     
        position : absolute;
        background-color : #ecf4ff;               
@@ -2084,19 +2064,7 @@ ul#headlineActionsBody li.insensitive:hover {
        color : gray;
 }
 
-div#extendedErrorBox {
-       left : 25%;
-       top : 70px;
-       width : 50%;
-       z-index : 999;
-       position : absolute;
-       min-width : 600px;
-       background-color : #ffcccc;
-       border : 1px solid #ff0000;
-       font-size : 12px;
-}
-
-div#extendedErrorBox div#xebTitle {
+div#errorBox div#xebTitle {
        background-color : #ff0000;
        color : white;
        padding : 4px 2px 4px 10px;
@@ -2105,16 +2073,18 @@ div#extendedErrorBox div#xebTitle {
        font-size : 12px;
 }
 
-div#extendedErrorBox div#xebContent {
+div#errorBox div#xebContent {
        font-size : 12px;
        padding : 10px;
 }
 
-div#extendedErrorBox textarea {
+div#errorBox textarea {
        width : 100%;
        height : 200px;
 }
 
-div#extendedErrorBox input {
+div#errorBox input {
        margin-bottom : 10px;
 }
+
+
index 1717cfbe27ad430d7c95df385ced05cf4ed88079..2b6f7f822bb3e0d0332dc84c0f9c896d4b4b1a41 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -131,14 +131,14 @@ function backend_sanity_check_callback(transport) {
                }
 
                if (!transport.responseXML) {
-                       fatalError(3, "[D001, Received reply is not XML]: " + transport.responseText);
+                       fatalError(3, "Sanity check: Received reply is not XML", transport.responseText);
                        return;
                }
 
                var reply = transport.responseXML.firstChild.firstChild;
 
                if (!reply) {
-                       fatalError(3, "[D002, Invalid RPC reply]: " + transport.responseText);
+                       fatalError(3, "Sanity check: invalid RPC reply", transport.responseText);
                        return;
                }
 
@@ -170,7 +170,7 @@ function backend_sanity_check_callback(transport) {
                init_second_stage();
 
        } catch (e) {
-               exception_error("backend_sanity_check_callback", e);    
+               exception_error("backend_sanity_check_callback", e, transport); 
        } 
 }
 
index 8f1dadd9e8349d929b2b4a0d440562599fd62111..5ab205e25ec312bfb0930c01a32d4d47f6c065c6 100644 (file)
 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 
-       <div id="extendedErrorBox" style="display : none">
-               <div id="xebTitle">Fatal Exception</div>
-               <div id="xebContent">&nbsp;</div>
-               <div align='center'>
-               <input type="submit" onclick="closeErrorBox()" value="Close this window"/>
-               </div>
-       </div>
-
        <script type="text/javascript">
        //<![CDATA[
                if (navigator.userAgent.match("Opera")) {
 
 <div id="notify" class="notify"><span id="notify_body">&nbsp;</span></div>
 
-<div id="fatal_error"><div id="fatal_error_inner">
-       <h1>Fatal Error</h1>
-       <div id="fatal_error_msg">Unknown Error</div>
-</div></div>
-
 <div id="dialog_overlay" style="display : none"> </div>
 
 <script type="text/javascript">
@@ -112,7 +99,15 @@ window.onload = init;
 
 <ul id="debug_output" style='display : none'><li>&nbsp;</li></ul>
 
-<div id="infoBoxShadow"><div id="infoBox">&nbsp;</div></div>
+<div id="infoBoxShadow" style="display : none"><div id="infoBox">&nbsp;</div></div>
+
+<div id="errorBoxShadow" style="display : none">
+       <div id="errorBox">
+               <div id="xebTitle">Fatal Exception</div><div id="xebContent">&nbsp;</div>
+               <div id="xebBtn" align='center'><input type="submit" 
+                       onclick="closeErrorBox()" value="Close this window"/></div>
+       </div>
+</div>
 
 <div id="header">
        <div class="topLinks">
index 489a014d6125f2bdc50e5cbb805f754a780a0238..0be41d7762ac16cce4828f8b2d7bf868702ddee8 100644 (file)
@@ -39,7 +39,7 @@ function catchup_callback2(transport, callback) {
                        setTimeout(callback, 10);       
                }
        } catch (e) {
-               exception_error("catchup_callback2", e);
+               exception_error("catchup_callback2", e, transport);
        }
 }
 
@@ -234,7 +234,7 @@ function headlines_callback2(transport, feed_cur_page) {
                remove_splash();
 
        } catch (e) {
-               exception_error_ext("headlines_callback2", e, transport);
+               exception_error("headlines_callback2", e, transport);
        }
 }
 
@@ -290,7 +290,7 @@ function showArticleInHeadlines(id) {
                        view_mode = document.forms['main_toolbar_form'].view_mode;      
                        view_mode = view_mode[view_mode.selectedIndex].value;
                } catch (e) {
-                       exception_error("showArticleInHeadlines/viewmode", e, true);
+                       //
                }
 
                if (upd_img_pic && upd_img_pic.src.match("updated.png")) {
@@ -386,7 +386,7 @@ function article_callback2(transport, id, feed_id) {
 
                notify("");
        } catch (e) {
-               exception_error("article_callback2", e);
+               exception_error("article_callback2", e, transport);
        }
 }