diff options
author | Jo-Philipp Wich <jo@mein.io> | 2023-08-21 09:28:18 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2023-08-21 09:48:29 +0200 |
commit | 86f04d85fc774db9cb7e60a34a50f936d8d7be23 (patch) | |
tree | b0bf6bc7e4cfebff7777ac529573c4cc653452a6 /modules/luci-base/ucode/dispatcher.uc | |
parent | ec8cf9e83cd4e4afdf0a00910e057a890600e8a8 (diff) |
luci-base: dispatcher.uc: improve error reporting for actionless nodes
In case a - potentially auto-created, intermediate - node is requested, reply
with a clean HTTP 404 error instead of an internal assertion about an unknown
action type.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/ucode/dispatcher.uc')
-rw-r--r-- | modules/luci-base/ucode/dispatcher.uc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/modules/luci-base/ucode/dispatcher.uc b/modules/luci-base/ucode/dispatcher.uc index f42155d539..8717385be2 100644 --- a/modules/luci-base/ucode/dispatcher.uc +++ b/modules/luci-base/ucode/dispatcher.uc @@ -772,7 +772,7 @@ function render_action(fn) { } function run_action(request_path, lang, tree, resolved, action) { - switch (action?.type) { + switch ((type(action) == 'object') ? action.type : 'none') { case 'template': if (runtime.is_ucode_template(action.path)) runtime.render(action.path, {}); @@ -840,14 +840,19 @@ function run_action(request_path, lang, tree, resolved, action) { break; case 'firstchild': - if (!length(tree.children)) + if (!length(tree.children)) { error404("No root node was registered, this usually happens if no module was installed.\n" + "Install luci-mod-admin-full and retry. " + "If the module is already installed, try removing the /tmp/luci-indexcache file."); - else - error404(`No page is registered at '/${entityencode(join("/", resolved.ctx.request_path))}'.\n` + - "If this url belongs to an extension, make sure it is properly installed.\n" + - "If the extension was recently installed, try removing the /tmp/luci-indexcache file."); + break; + } + + /* fall through */ + + case 'none': + error404(`No page is registered at '/${entityencode(join("/", resolved.ctx.request_path))}'.\n` + + "If this url belongs to an extension, make sure it is properly installed.\n" + + "If the extension was recently installed, try removing the /tmp/luci-indexcache file."); break; default: |