summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs
diff options
context:
space:
mode:
authorGiovanni Giacobbi <giovanni@giacobbi.net>2021-01-18 10:50:43 +0100
committerGiovanni Giacobbi <giovanni@giacobbi.net>2021-01-19 22:46:25 +0100
commit763158600a348b0d4b16b0b8bef052b213d92d2b (patch)
treefb1c6bf7739dfd2506e75709b3810acc47ff8819 /modules/luci-base/htdocs
parentbce961729d580cf9f1468d6a36d881e53b055741 (diff)
luci-base: luci.js: fix `LuCI.request.poll.add()` exception handling
The try/catch is meant for the `res.json()` call and should apply to that. As it was before, an exception inside the poll callback would cause the callback to be reinvoked without the JSON parameter, which is an odd behaviour. Moreover, it makes it hard to debug because it is completely hidden from the browser console. We now differentiate between exceptions thrown due to bad JSON in `responseText` from exceptions generated inside the callback itself, which are let through for browser console logging. Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
Diffstat (limited to 'modules/luci-base/htdocs')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/luci.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js
index faed3aa6d2..eeb48530c8 100644
--- a/modules/luci-base/htdocs/luci-static/resources/luci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/luci.js
@@ -982,12 +982,13 @@
if (!Poll.active())
return;
+ var res_json = null;
try {
- callback(res, res.json(), res.duration);
- }
- catch (err) {
- callback(res, null, res.duration);
+ res_json = res.json();
}
+ catch (err) {}
+
+ callback(res, res_json, res.duration);
});
};