From: Chris Hofstaedtler Date: Tue, 2 Aug 2022 07:29:49 +0000 (+0200) Subject: rec: improve network error handling X-Git-Tag: rec-4.8.0-alpha1~65^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=247dbad7132411c750b259d78cc12b4b8a6115f1;p=thirdparty%2Fpdns.git rec: improve network error handling --- diff --git a/pdns/recursordist/html/local.js b/pdns/recursordist/html/local.js index 5512a983ce..93af0ba5c4 100644 --- a/pdns/recursordist/html/local.js +++ b/pdns/recursordist/html/local.js @@ -15,10 +15,10 @@ function get_json(url, params) { if (response.ok) { response.json().then((json) => resolve(json)); } else { - reject({status: response.status, statusText: response.statusText}); + reject(`HTTP Status ${response.status} ${response.statusText}`); } - }).catch((reason) => { - reject(reason); + }).catch((error) => { + reject(error.message); }) }); } @@ -156,14 +156,14 @@ function startup() { }); } - var connectionOK = function (ok, o) { + var connectionOK = function (ok, reason) { if (ok) { document.querySelector("#connection-status").style.display = "none"; document.querySelector("#connection-error").innerHTML = ""; document.querySelector("#content-hidden-on-load").style.display = "inherit"; } else { document.querySelector("#connection-status").style.display = "inherit"; - document.querySelector("#connection-error").innerHTML = o.status + " " + o.statusText; + document.querySelector("#connection-error").innerHTML = reason; } };