2
0
Эх сурвалжийг харах

Catch some more file-opening exceptions and make them lua errors instead

Bart van Strien 14 жил өмнө
parent
commit
453593c9b0

+ 6 - 1
src/modules/filesystem/physfs/wrap_Filesystem.cpp

@@ -218,7 +218,12 @@ namespace physfs
 
 
 	int w_load(lua_State * L)
 	int w_load(lua_State * L)
 	{
 	{
-		return instance->load(L);
+		try {
+			return instance->load(L);
+		}
+		catch (love::Exception & e) {
+			return luaL_error(L, e.what());
+		}
 	}
 	}
 
 
 	int w_getLastModified(lua_State * L)
 	int w_getLastModified(lua_State * L)

+ 8 - 1
src/modules/thread/sdl/wrap_Thread.cpp

@@ -286,7 +286,14 @@ namespace sdl
 		if (lua_isstring(L, 2))
 		if (lua_isstring(L, 2))
 			luax_convobj(L, 2, "filesystem", "newFile");
 			luax_convobj(L, 2, "filesystem", "newFile");
 		if (luax_istype(L, 2, FILESYSTEM_FILE_T))
 		if (luax_istype(L, 2, FILESYSTEM_FILE_T))
-			data = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T)->read();
+		{
+			Data * d;
+			try {
+				data = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T)->read();
+			} catch (love::Exception & e) {
+				return luaL_error(L, e.what());
+			}
+		}
 		else
 		else
 			data = luax_checktype<love::Data>(L, 2, "Data", DATA_T);
 			data = luax_checktype<love::Data>(L, 2, "Data", DATA_T);
 		Thread *t = instance->newThread(name, data);
 		Thread *t = instance->newThread(name, data);