# HG changeset patch
# User Waqas Hussain <waqas20@gmail.com>
# Date 1226186785 -18000
# Node ID 01bd24ea488dbe28324c6abf766bd1e9246931b8
# Parent  8758422358360cb02b6d86d32de2420a89b70c94
We now fail if modules fail to load at startup.

diff -r 875842235836 -r 01bd24ea488d core/modulemanager.lua
--- a/core/modulemanager.lua	Sun Nov 09 03:33:38 2008 +0500
+++ b/core/modulemanager.lua	Sun Nov 09 04:26:25 2008 +0500
@@ -68,7 +68,7 @@
 	local mod, err = loadfile("plugins/mod_"..name..".lua");
 	if not mod then
 		log("error", "Unable to load module '%s': %s", name or "nil", err or "nil");
-		return;
+		return nil, err;
 	end
 	
 	local pluginenv = setmetatable({ module = { name = name } }, { __index = modulehelpers });
@@ -77,8 +77,9 @@
 	local success, ret = pcall(mod);
 	if not success then
 		log("error", "Error initialising module '%s': %s", name or "nil", ret or "nil");
-		return;
+		return nil, err;
 	end
+	return true;
 end
 
 function handle_stanza(origin, stanza)
diff -r 875842235836 -r 01bd24ea488d main.lua
--- a/main.lua	Sun Nov 09 03:33:38 2008 +0500
+++ b/main.lua	Sun Nov 09 04:26:25 2008 +0500
@@ -41,7 +41,9 @@
 -- Initialise modules
 if config.modules and #config.modules > 0 then
 	for _, module in pairs(config.modules) do
-		modulemanager.load(module);
+		if not modulemanager.load(module) then
+			error("Unable to load module "..module);
+		end
 	end
 else error("No modules enabled in the configuration file"); end