mod_console: Fixed traceback occuring on using module:list on unknown hosts.

Sun, 18 Oct 2009 18:10:05 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sun, 18 Oct 2009 18:10:05 +0500
changeset 2010
1a4f14ea39b6
parent 2009
3f9cce29c57d
child 2011
8159497c86e3

mod_console: Fixed traceback occuring on using module:list on unknown hosts.

plugins/mod_console.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_console.lua	Sun Oct 18 18:01:13 2009 +0500
+++ b/plugins/mod_console.lua	Sun Oct 18 18:10:05 2009 +0500
@@ -345,9 +345,13 @@
 	local print = self.session.print;
 	for _, host in ipairs(hosts) do
 		print(host..":");
-		local modules = array.collect(keys(prosody.hosts[host].modules or {})):sort();
+		local modules = array.collect(keys(prosody.hosts[host] and prosody.hosts[host].modules or {})):sort();
 		if #modules == 0 then
-			print("    No modules loaded");
+			if prosody.hosts[host] then
+				print("    No modules loaded");
+			else
+				print("    Host not found");
+			end
 		else
 			for _, name in ipairs(modules) do
 				print("    "..name);

mercurial