From d131c0c883b783778b79f3c28f48da9bc0e20432 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Sun, 28 Nov 2010 04:16:37 -0600 Subject: [PATCH] love.graphics.newFont now errors if the specified file doesn't exist (fixes #115) --- src/modules/graphics/opengl/wrap_Graphics.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index e83fddff9..676f6511b 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -213,7 +213,13 @@ namespace opengl // Convert to Data, if necessary. if(luax_istype(L, 1, FILESYSTEM_FILE_T)) { love::filesystem::File * f = luax_checktype(L, 1, "File", FILESYSTEM_FILE_T); - Data * d = f->read(); + Data * d; + try { + d = f->read(); + } + catch (love::Exception & e) { + return luaL_error(L, e.what()); + } lua_remove(L, 1); // get rid of the file luax_newtype(L, "Data", DATA_T, (void*)d); lua_insert(L, 1); // put it at the bottom of the stack