if not luci.util.copcall(luci.template.render, "error404") then
luci.http.prepare_content("text/plain")
luci.http.write(message)
+ luci.util.perror(message)
end
return false
end
-- @param message Custom error message (optional)#
-- @return false
function error500(message)
- luci.http.status(500, "Internal Server Error")
-
- require("luci.template")
- if not luci.util.copcall(luci.template.render, "error500", {message=message}) then
- luci.http.prepare_content("text/plain")
- luci.http.write(message)
+ if not context.template_header_sent then
+ luci.http.status(500, "Internal Server Error")
+ else
+ require("luci.template")
+ if not luci.util.copcall(luci.template.render, "error500", {message=message}) then
+ luci.http.prepare_content("text/plain")
+ luci.http.write(message)
+ end
end
return false
end
table.insert(context.request, node)
end
- local stat, err = util.copcall(dispatch, context.request)
- if not stat then
- luci.util.perror(err)
- error500(err)
- end
+ local stat, err = util.coxpcall(function()
+ dispatch(context.request)
+ end, error500)
luci.http.close()
local function _call(self, ...)
- if #self.argv > 0 then
+ if #self.argv > 0 then
return getfenv()[self.name](unpack(self.argv), ...)
else
return getfenv()[self.name](...)