From 15cbc4d03ede8002ee850ec84784411534adda9d Mon Sep 17 00:00:00 2001
From: Waqas Hussain <waqas20@gmail.com>
Date: Tue, 13 Jan 2009 23:16:39 +0500
Subject: modulemanager: Check for syntax errors before reloading a module

---
 core/modulemanager.lua | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'core')

diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index c1caaacc..d8914ccc 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -164,6 +164,12 @@ function reload(host, name, ...)
 	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)
-- 
cgit v1.2.3