summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/dispatcher.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-05-31 17:41:40 +0200
committerJo-Philipp Wich <jo@mein.io>2018-05-31 17:45:49 +0200
commit298d164dd7a3bce42dc37fab238d28fab4708582 (patch)
treeff31d547fb5c4e0cd120a06f341e6bdc8469d982 /modules/luci-base/luasrc/dispatcher.lua
parent79d793dffe7b67220fd38fc447bd72403c032b93 (diff)
luci-base: update coxpcall() implementation, fix runtime error reporting
Sync our coxpcall() implementation to the newest upstream version in order to get access to the inner backtrace information and propagate these traces to the browser in luci.dispatcher.dispatch(). This should make tracking down runtime errors much easier. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc/dispatcher.lua')
-rw-r--r--modules/luci-base/luasrc/dispatcher.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua
index 2c58b0ab3d..6850d7e3a9 100644
--- a/modules/luci-base/luasrc/dispatcher.lua
+++ b/modules/luci-base/luasrc/dispatcher.lua
@@ -358,7 +358,7 @@ function dispatch(request)
elseif key == "REQUEST_URI" then
return build_url(unpack(ctx.requestpath))
elseif key == "FULL_REQUEST_URI" then
- local url = { http.getenv("SCRIPT_NAME") or "" , http.getenv("PATH_INFO") }
+ local url = { http.getenv("SCRIPT_NAME") or "", http.getenv("PATH_INFO") }
local query = http.getenv("QUERY_STRING")
if query and #query > 0 then
url[#url+1] = "?"
@@ -507,10 +507,11 @@ function dispatch(request)
else
ok, err = util.copcall(target, unpack(args))
end
- assert(ok,
- "Failed to execute " .. (type(c.target) == "function" and "function" or c.target.type or "unknown") ..
- " dispatcher target for entry '/" .. table.concat(request, "/") .. "'.\n" ..
- "The called action terminated with an exception:\n" .. tostring(err or "(unknown)"))
+ if not ok then
+ error500("Failed to execute " .. (type(c.target) == "function" and "function" or c.target.type or "unknown") ..
+ " dispatcher target for entry '/" .. table.concat(request, "/") .. "'.\n" ..
+ "The called action terminated with an exception:\n" .. tostring(err or "(unknown)"))
+ end
else
local root = node()
if not root or not root.target then