From ce34e92c7a50f1f9532924e3e118819443bb88da Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 23 Jun 2020 20:40:13 +0100 Subject: [PATCH] client lookup for /_/updates, error handling --- templates/script.js | 15 ++++++++++++++- templates/test.tera | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/templates/script.js b/templates/script.js index 0fbdd3e2..96034fa5 100644 --- a/templates/script.js +++ b/templates/script.js @@ -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(){ diff --git a/templates/test.tera b/templates/test.tera index d03e8d43..e8eef9b0 100644 --- a/templates/test.tera +++ b/templates/test.tera @@ -1,6 +1,7 @@

Hi!

- +
+

nothing

-- 2.30.2