fix(loadFramework): catch error during load

This commit is contained in:
Linden
2022-04-22 15:29:20 +10:00
parent 8c448db68d
commit d70fa5de82

View File

@@ -28,6 +28,7 @@ return function()
err(import and import or ('no loader exists for %s'):format(framework), 1) err(import and import or ('no loader exists for %s'):format(framework), 1)
end end
-- Return early since framework does not use an imports file
if type(import) == 'table' then if type(import) == 'table' then
import.resource = framework import.resource = framework
return import return import
@@ -43,21 +44,16 @@ return function()
err(result and result or ("unable to load '@%s/%s'"):format(framework, import), 0) err(result and result or ("unable to load '@%s/%s'"):format(framework, import), 0)
end end
if success then success, result = load(result, ('@@%s/%s'):format(framework, import))
success, result = pcall(load, result, ('@@%s/%s'):format(framework, import), 't')
if not result then if not success then
-- TODO: catch the error that pcall somehow doesn't catch? err(result, 0)
err(("an unknown error occured while loading '@%s/%s'"):format(framework, import))
end
if success then
success, result = pcall(result)
if not success then err(result) end
end
end end
success, result = pcall(result)
if not success then err(result) end
if framework == 'ox_core' then if framework == 'ox_core' then
import = Ox import = Ox
elseif framework == 'es_extended' then elseif framework == 'es_extended' then