scripts: feature_lib.lua: improve error handling for invalid feature files

Print a proper error message, rather than just

    openwrt/staging_dir/hostpkg/bin/lua: scripts/feature_lib.lua:48: bad
    argument #1 to 'setfenv' (integer expected, got nil)
This commit is contained in:
Matthias Schiffer 2020-08-28 20:34:54 +02:00
parent b1294472c6
commit 097efa9d2d
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
1 changed files with 4 additions and 1 deletions

View File

@ -43,7 +43,10 @@ function M.get_packages(file, features)
end
-- Evaluate the feature definition file
local f = loadfile(file)
local f, err = loadfile(file)
if not f then
error('Failed to parse feature definition: ' .. err)
end
setfenv(f, funcs)
f()