luci-base: template.lua: fix nil access in string template error handling

Template strings have no associated name, which led to an attempt to
concat nil with a string when formatting the error message in case of
exceptions.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2020-06-19 14:49:48 +02:00
parent 40f28a1582
commit c351beea56

View file

@ -71,7 +71,7 @@ function Template.__init__(self, name, template)
-- If we have no valid template throw error, otherwise cache the template -- If we have no valid template throw error, otherwise cache the template
if not self.template then if not self.template then
error("Failed to load template '" .. name .. "'.\n" .. error("Failed to load template '" .. self.name .. "'.\n" ..
"Error while parsing template '" .. sourcefile .. "':\n" .. "Error while parsing template '" .. sourcefile .. "':\n" ..
(err or "Unknown syntax error")) (err or "Unknown syntax error"))
elseif name then elseif name then