# HG changeset patch # User Kim Alvefur # Date 1527565819 -7200 # Node ID cefc375d092925b138270b32bdd12b624df60899 # Parent 49254b9cc7519f54961b0c8577be13169ad712aa mod_http_muc_log: Handle errors while loading template file in a more graceful manner diff -r 49254b9cc751 -r cefc375d0929 mod_http_muc_log/mod_http_muc_log.lua --- a/mod_http_muc_log/mod_http_muc_log.lua Tue May 29 05:04:52 2018 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Tue May 29 05:50:19 2018 +0200 @@ -32,9 +32,16 @@ local template; do local template_filename = module:get_option_string(module.name .. "_template", module.name .. ".html"); - local template_file = assert(module:load_resource(template_filename)); - template = template_file:read("*a"); - template_file:close(); + local template_file, err = module:load_resource(template_filename); + if template_file then + template, err = template_file:read("*a"); + template_file:close(); + end + if not template then + module:log("error", "Error loading template: %s", err); + template = render("

mod_{module} could not read the template

Tried to open {filename}

{error}
", + { module = module.name, filename = template_filename, error = err }); + end end -- local base_url = module:http_url() .. '/'; -- TODO: Generate links in a smart way