modulemanager: Check for syntax errors before reloading a module

Tue, 13 Jan 2009 23:16:39 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Tue, 13 Jan 2009 23:16:39 +0500
changeset 713
2afd6d9e21cd
parent 712
56410c0cd846
child 714
ab3c47f4fe1d

modulemanager: Check for syntax errors before reloading a module

core/modulemanager.lua file | annotate | diff | comparison | revisions
--- a/core/modulemanager.lua	Tue Jan 13 22:39:07 2009 +0500
+++ b/core/modulemanager.lua	Tue Jan 13 23:16:39 2009 +0500
@@ -164,6 +164,12 @@
 	local mod = modulemap[host] and modulemap[host][name];
 	if not mod then return nil, "module-not-loaded"; end
 
+	local _mod, err = loadfile(plugin_dir.."mod_"..name..".lua"); -- checking for syntax errors
+	if not _mod then
+		log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
+		return nil, err;
+	end
+
 	local saved;
 	if type(mod.module.save) == "function" then
 		local ok, err = pcall(mod.module.save)

mercurial