load_script error handling fix

This commit is contained in:
MihailRis 2024-02-05 07:02:50 +03:00
parent 4ad48bdb63
commit becd1d11ae

View File

@ -37,10 +37,14 @@ function load_script(path, nocache)
if not nocache and __cached_scripts[fullpath] ~= nil then if not nocache and __cached_scripts[fullpath] ~= nil then
return __cached_results[fullpath] return __cached_results[fullpath]
end end
local script = loadfile(fullpath) if not file.isfile(fullpath) then
if script == nil then
error("script '"..filename.."' not found in '"..packname.."'") error("script '"..filename.."' not found in '"..packname.."'")
end end
local script, err = loadfile(fullpath)
if script == nil then
error(err)
end
local result = script() local result = script()
if not nocache then if not nocache then
__cached_scripts[fullpath] = script __cached_scripts[fullpath] = script