diff options
author | Steven Barth <steven@midlink.org> | 2008-08-30 20:32:00 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-08-30 20:32:00 +0000 |
commit | cec13fcb294a9146226a80766b798b392fa90ce9 (patch) | |
tree | 452b9f2a0ab1fd2125e744d01b6c1f8017bb583f /libs | |
parent | 171cbec25d279c3913e781c49f3061edc51c15c1 (diff) |
libs/web: Return more verbose error messages when template execution fails
Diffstat (limited to 'libs')
-rw-r--r-- | libs/web/luasrc/template.lua | 6 |
1 files changed, 5 insertions, 1 deletions
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) |