Skip to content

Commit e365728

Browse files
committed
Simulator: protected calls for plugin collectors
1 parent 84d2bc5 commit e365728

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

platform/resources/CoronaBuilderPluginCollector.lua

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,23 @@ local function fetchSinglePluginNoFallbacks(dstDir, plugin, pluginTable, pluginP
358358
local ok = false
359359
for i = 1,#pluginLocators do
360360
local locator = pluginLocators[i]
361-
local result
361+
local success, result
362362
if type(locator) == 'table' then
363363
if not locator.initialized and type(locator.init) == 'function' then
364-
locator:init(params)
364+
success, result = pcall(locator.init, locator, params)
365+
if not success then
366+
print("WARNING: error initializing plugin locator " .. (locatorName(locator) or "<unknown>") .. ": " .. tostring(result))
367+
end
365368
locator.initialized = true
366369
end
367-
result = locator:collect(pluginDestination, plugin, pluginTable, pluginPlatform, params)
370+
success, result = pcall(locator.collect, locator, pluginDestination, plugin, pluginTable, pluginPlatform, params)
368371
else
369-
result = locator(pluginDestination, plugin, pluginTable, pluginPlatform, params)
372+
success, result = pcall(locator, pluginDestination, plugin, pluginTable, pluginPlatform, params)
373+
end
374+
if not success then
375+
print("WARNING: runtime error while executing plugin locator " .. (locatorName(locator) or "<unknown>") .. ": " .. tostring(result))
370376
end
371-
if result == true then
377+
if success and result == true then
372378
log("Located " .. plugin .. " with locator " .. (locatorName(locator) or "<unknown>"))
373379
ok = true
374380
break
@@ -462,8 +468,8 @@ local function CollectCoronaPlugins(params)
462468
local pluginPlatform = params.pluginPlatform
463469
local collectedPlugins = {}
464470
for plugin, pluginTable in pairs(plugins) do
465-
assert(type(plugin) == 'string', "Plugin is not a string")
466-
assert(type(pluginTable) == 'table', 'Invalid plugin table for ' .. plugin)
471+
if type(plugin) ~= 'string' then return "Plugin is not a string" end
472+
if type(pluginTable) ~= 'table' then return 'Invalid plugin table for ' .. plugin end
467473
local result = fetchSinglePlugin(dstDir, plugin, pluginTable, pluginPlatform, params, pluginLocators)
468474
if type(result) == 'string' then
469475
if params.continueOnError then

0 commit comments

Comments
 (0)