Improve lovr.filesystem.load errors;
Lua was happily compiling nil chunks and making them return empty
strings, which was not a good error experience in situations where
your file couldn't be loaded properly.  Now we return nil plus an
error message, which matches LOVE and other Lua conventions.
@@ -59,6 +59,11 @@ static void pushDirectoryItem(void* context, const char* path) {
static int luax_loadfile(lua_State* L, const char* path, const char* debug) {
size_t size;
void* buffer = luax_readfile(path, &size);
+ if (!buffer) {
+ lua_pushnil(L);
+ lua_pushfstring(L, "Could not load file '%s'", path);
+ return 2;
+ }
int status = luaL_loadbuffer(L, buffer, size, debug);
free(buffer);
switch (status) {
