From 9c84c781290a670ca9734788b49f1ea0d45efe12 Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 10 Aug 2015 12:44:27 -0400 Subject: [PATCH] Make lua listdir functions return useful error messages --- library/LuaApi.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 0e507dafe..c23cfe22a 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -2209,7 +2209,14 @@ static int filesystem_listdir(lua_State *L) luaL_checktype(L,1,LUA_TSTRING); std::string dir=lua_tostring(L,1); std::vector files; - DFHack::Filesystem::listdir(dir, files); + int err = DFHack::Filesystem::listdir(dir, files); + if (err) + { + lua_pushnil(L); + lua_pushstring(L, strerror(err)); + lua_pushinteger(L, err); + return 3; + } lua_newtable(L); for(int i=0;i