]> git.wh0rd.org Git - tt-rss.git/commitdiff
better javascript error reporting, save error reports in tt-rss log
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 20 Apr 2013 06:43:21 +0000 (10:43 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 20 Apr 2013 06:43:21 +0000 (10:43 +0400)
classes/rpc.php
js/functions.js

index 61c815b360113a110316dfab016f21f3428613ed..750aa2cb1399835ac4bc5a26ec307fd7c3ab45b7 100644 (file)
@@ -634,5 +634,16 @@ class RPC extends Handler_Protected {
                }
        }
 
+       function log() {
+               $logmsg = $this->dbh->escape_string($_REQUEST['logmsg']);
+
+               if ($logmsg) {
+                       Logger::get()->log_error(E_USER_WARNING,
+                               $logmsg, '[client-js]', 0, false);
+               }
+
+               echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
+
+       }
 }
 ?>
index 04be58bf77a2961b7dd2ef3afe29f013fad080eb..8442e1c9fc0f5039d3e6c1227df57805f15f7062 100644 (file)
@@ -50,6 +50,21 @@ function exception_error(location, e, ext_info) {
                        }
                }
 
+               try {
+                       new Ajax.Request("backend.php", {
+                               parameters: {op: "rpc", method: "log", logmsg: msg},
+                               onComplete: function (transport) {
+                                       console.log(transport.responseText);
+                               } });
+
+               } catch (eii) {
+                       console.log("Exception while trying to log the error.");
+                       console.log(eii);
+               }
+
+               msg += "<p>"+ __("The error will be reported to the configured log destination.") +
+                       "</p>";
+
                var content = "<div class=\"fatalError\">" +
                        "<pre>" + msg + "</pre>";
 
@@ -106,7 +121,28 @@ function exception_error(location, e, ext_info) {
 
                dialog.show();
 
-       } catch (e) {
+       } catch (ei) {
+               console.log("Exception while trying to report an exception. Oh boy.");
+               console.log(ei);
+               console.log("Original exception:");
+               console.log(e);
+
+               msg += "\n\nAdditional exception caught while trying to show the error dialog.\n\n" +  format_exception_error('exception_error', ei);
+
+               try {
+                       new Ajax.Request("backend.php", {
+                               parameters: {op: "rpc", method: "log", logmsg: msg},
+                               onComplete: function (transport) {
+                                       console.log(transport.responseText);
+                               } });
+
+               } catch (eii) {
+                       console.log("Third exception while trying to log the error! Seriously?");
+                       console.log(eii);
+               }
+
+               msg += "\n\nThe error will be reported to the configured log destination.";
+
                alert(msg);
        }