luci-base: luci.js: fix `LuCI.request.poll.add()` exception handling 4742/head
authorGiovanni Giacobbi <giovanni@giacobbi.net>
Mon, 18 Jan 2021 09:50:43 +0000 (10:50 +0100)
committerGiovanni Giacobbi <giovanni@giacobbi.net>
Tue, 19 Jan 2021 21:46:25 +0000 (22:46 +0100)
commit763158600a348b0d4b16b0b8bef052b213d92d2b
treefb1c6bf7739dfd2506e75709b3810acc47ff8819
parentbce961729d580cf9f1468d6a36d881e53b055741
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>
modules/luci-base/htdocs/luci-static/resources/luci.js