plugin(fix): catch plugin crash at init time
This commit is contained in:
1 parent
16192d2354
commit
fd862f5e28
3 files changed
+31
-10
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user