plugin(fix): catch plugin crash at init time

This commit is contained in:
Qingping Hou committed 2017-04-22 00:22:37 -07:00
1 parent 16192d2354
commit fd862f5e28
3 files changed
+31 -10

No files matched your search

+10
View File
@@ -68,4 +68,14 @@ function PluginLoader:loadPlugins()
return self.plugins
end
function PluginLoader:createPluginInstance(plugin, attr)
local ok, re = pcall(plugin.new, plugin, attr)
if ok then -- re is a plugin instance
return ok, re
else -- re is the error message
logger.err('Failed to initialize', plugin.name, 'plugin: ', re)
return nil, re
end
end
return PluginLoader