From cec13fcb294a9146226a80766b798b392fa90ce9 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sat, 30 Aug 2008 20:32:00 +0000 Subject: libs/web: Return more verbose error messages when template execution fails --- libs/web/luasrc/template.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libs') diff --git a/libs/web/luasrc/template.lua b/libs/web/luasrc/template.lua index 907403fcb..d49bceac7 100644 --- a/libs/web/luasrc/template.lua +++ b/libs/web/luasrc/template.lua @@ -144,6 +144,7 @@ setmetatable(Template.cache, {__mode = "v"}) -- Constructor - Reads and compiles the template on-demand function Template.__init__(self, name) self.template = self.cache[name] + self.name = name -- Create a new namespace for this template self.viewns = {} @@ -226,7 +227,10 @@ function Template.render(self, scope) luci.util.updfenv(self.template, self.viewns) -- Now finally render the thing - self.template() + local stat, err = luci.util.copcall(self.template) + if not stat then + error("Error in template %s: %s" % {self.name, err}) + end -- Reset environment setfenv(self.template, oldfenv) -- cgit v1.2.3