From 453593c9b0331b71c5708fecbec4908f3e10ad72 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Fri, 18 Feb 2011 16:10:20 +0100 Subject: [PATCH] Catch some more file-opening exceptions and make them lua errors instead --- src/modules/filesystem/physfs/wrap_Filesystem.cpp | 7 ++++++- src/modules/thread/sdl/wrap_Thread.cpp | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/filesystem/physfs/wrap_Filesystem.cpp b/src/modules/filesystem/physfs/wrap_Filesystem.cpp index 3cfad6eb0..9d1c2c15c 100644 --- a/src/modules/filesystem/physfs/wrap_Filesystem.cpp +++ b/src/modules/filesystem/physfs/wrap_Filesystem.cpp @@ -218,7 +218,12 @@ namespace physfs 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) diff --git a/src/modules/thread/sdl/wrap_Thread.cpp b/src/modules/thread/sdl/wrap_Thread.cpp index 2be23b951..9d58f5155 100644 --- a/src/modules/thread/sdl/wrap_Thread.cpp +++ b/src/modules/thread/sdl/wrap_Thread.cpp @@ -286,7 +286,14 @@ namespace sdl if (lua_isstring(L, 2)) luax_convobj(L, 2, "filesystem", "newFile"); if (luax_istype(L, 2, FILESYSTEM_FILE_T)) - data = luax_checktype(L, 2, "File", FILESYSTEM_FILE_T)->read(); + { + Data * d; + try { + data = luax_checktype(L, 2, "File", FILESYSTEM_FILE_T)->read(); + } catch (love::Exception & e) { + return luaL_error(L, e.what()); + } + } else data = luax_checktype(L, 2, "Data", DATA_T); Thread *t = instance->newThread(name, data);