Changeset

2010:1a4f14ea39b6

mod_console: Fixed traceback occuring on using module:list on unknown hosts.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 18 Oct 2009 18:10:05 +0500
parents 2009:3f9cce29c57d
children 2011:8159497c86e3
files plugins/mod_console.lua
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);