chiark / gitweb /
client lookup for /_/updates, error handling
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 23 Jun 2020 19:40:13 +0000 (20:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 23 Jun 2020 19:40:13 +0000 (20:40 +0100)
templates/script.js
templates/test.tera

index 0fbdd3e22482adba2cb3222195dba700cf41f658..96034fa5f6f82e490d8cdc1a6db385f3b5f5d17e 100644 (file)
@@ -20,10 +20,14 @@ function xhr_post_then(url,data,good) {
 }
 
 function xhr_report_error(xhr) {
-  let error_message = JSON.stringify({
+  json_report_error({
     statusText : xhr.statusText,
     responseText : xhr.responseText,
   });
+}
+
+function json_report_error(error_json) {
+  let error_message = JSON.stringify(error_json);
   let errornode = document.getElementById('error');
   errornode.textContent = 'Error (reloading may help?):' + error_message;
 }
@@ -97,6 +101,15 @@ function startup() {
     var k = Object.keys(j)[0];
     messages[k](j[k]);
   }
+  es.onerror = function(e) {
+    console.log('FOO',e,es);
+    json_report_error({
+      updates_error : e,
+      updates_event_source : es,
+      updates_event_source_ready : es.readyState,
+      update_oe : e.className,
+    })
+  }
 }
 
 function doload(){
index d03e8d4334c9afcb866b26f7b470a5a4dec7b504..e8eef9b0c0a7f564dbbe7db42d92280ce075616a 100644 (file)
@@ -1,6 +1,7 @@
 <body>
 <h1>Hi!</h1>
-
+<div id="error"></div>
+<p>
 <div id="status">nothing</div>
 
 <p>