]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: improve network error handling
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Tue, 2 Aug 2022 07:29:49 +0000 (09:29 +0200)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Tue, 2 Aug 2022 07:29:49 +0000 (09:29 +0200)
pdns/recursordist/html/local.js

index 5512a983ced8bce162ef5a65305b5ebfa551751b..93af0ba5c4a82afd85c3f3c7da9f6196b4d2dfc8 100644 (file)
@@ -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;
         }
     };