mod_console: Fixed traceback occuring on using module:list on unknown hosts.
authorWaqas Hussain <waqas20@gmail.com>
Sun, 18 Oct 2009 13:10:05 +0000 (18:10 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Sun, 18 Oct 2009 13:10:05 +0000 (18:10 +0500)
plugins/mod_console.lua

index 19c22c916b3c5f9863c5da45fe03dddbb47c1e96..a46eec12b7d96c39de0d6ed9152155eb43c9ad13 100644 (file)
@@ -345,9 +345,13 @@ function def_env.module:list(hosts)
        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);