Software /
code /
prosody
Comparison
core/modulemanager.lua @ 229:01bd24ea488d
We now fail if modules fail to load at startup.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 09 Nov 2008 04:26:25 +0500 |
parent | 218:1263896ab2f1 |
child | 300:0ebf2ef5124e |
comparison
equal
deleted
inserted
replaced
228:875842235836 | 229:01bd24ea488d |
---|---|
66 | 66 |
67 function load(name) | 67 function load(name) |
68 local mod, err = loadfile("plugins/mod_"..name..".lua"); | 68 local mod, err = loadfile("plugins/mod_"..name..".lua"); |
69 if not mod then | 69 if not mod then |
70 log("error", "Unable to load module '%s': %s", name or "nil", err or "nil"); | 70 log("error", "Unable to load module '%s': %s", name or "nil", err or "nil"); |
71 return; | 71 return nil, err; |
72 end | 72 end |
73 | 73 |
74 local pluginenv = setmetatable({ module = { name = name } }, { __index = modulehelpers }); | 74 local pluginenv = setmetatable({ module = { name = name } }, { __index = modulehelpers }); |
75 | 75 |
76 setfenv(mod, pluginenv); | 76 setfenv(mod, pluginenv); |
77 local success, ret = pcall(mod); | 77 local success, ret = pcall(mod); |
78 if not success then | 78 if not success then |
79 log("error", "Error initialising module '%s': %s", name or "nil", ret or "nil"); | 79 log("error", "Error initialising module '%s': %s", name or "nil", ret or "nil"); |
80 return; | 80 return nil, err; |
81 end | 81 end |
82 return true; | |
82 end | 83 end |
83 | 84 |
84 function handle_stanza(origin, stanza) | 85 function handle_stanza(origin, stanza) |
85 local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns, origin.type; | 86 local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns, origin.type; |
86 | 87 |