Software / code / prosody
Comparison
core/modulemanager.lua @ 713:2afd6d9e21cd
modulemanager: Check for syntax errors before reloading a module
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Tue, 13 Jan 2009 23:16:39 +0500 |
| parent | 710:56f6c115bc69 |
| child | 733:b1aedec00661 |
comparison
equal
deleted
inserted
replaced
| 712:56410c0cd846 | 713:2afd6d9e21cd |
|---|---|
| 162 | 162 |
| 163 function reload(host, name, ...) | 163 function reload(host, name, ...) |
| 164 local mod = modulemap[host] and modulemap[host][name]; | 164 local mod = modulemap[host] and modulemap[host][name]; |
| 165 if not mod then return nil, "module-not-loaded"; end | 165 if not mod then return nil, "module-not-loaded"; end |
| 166 | 166 |
| 167 local _mod, err = loadfile(plugin_dir.."mod_"..name..".lua"); -- checking for syntax errors | |
| 168 if not _mod then | |
| 169 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); | |
| 170 return nil, err; | |
| 171 end | |
| 172 | |
| 167 local saved; | 173 local saved; |
| 168 if type(mod.module.save) == "function" then | 174 if type(mod.module.save) == "function" then |
| 169 local ok, err = pcall(mod.module.save) | 175 local ok, err = pcall(mod.module.save) |
| 170 if (not ok) and err then | 176 if (not ok) and err then |
| 171 log("warn", "Non-fatal error unloading module '%s' from '%s': %s", name, host, err); | 177 log("warn", "Non-fatal error unloading module '%s' from '%s': %s", name, host, err); |