1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

pkg/lua: Make the module searchers conform to the API.

The module searchers in the `require` package should return a string
if the module is not found, and not raise an error.

See: https://www.lua.org/manual/5.3/manual.html#pdf-package.searchers

Also make error strings contain newlines and tabs just like the original
ones.
This commit is contained in:
Juan Carrano 2018-08-07 13:59:44 +02:00
parent e31ef56eae
commit fe07bff90c

View File

@ -79,8 +79,8 @@ static int searcher_builtin_lua(lua_State *L)
case LUA_OK:
return 2; /* there are two elements in the stack */
case LUAR_MODULE_NOTFOUND:
return luaL_error(L, "Module '%s' not found in Lua-builtins",
lua_tostring(L, 1));
lua_pushliteral(L, "\n\tModule not found in Lua-builtins");
return 1;
default:
return luaL_error(L, "error loading module '%s' from Lua-builtins: \n%s",
lua_tostring(L, 1), lua_tostring(L, 2));
@ -119,8 +119,8 @@ static int searcher_builtin_c(lua_State *L)
return 2;
}
else {
return luaL_error(L, "Module '%s' not found in C-builtins",
lua_tostring(L, 1));
lua_pushliteral(L, "\n\tModule not found in C-builtins");
return 1;
}
}