diff --git a/sol/function.hpp b/sol/function.hpp index a1b8f925..2837dfd7 100644 --- a/sol/function.hpp +++ b/sol/function.hpp @@ -170,7 +170,7 @@ private: returncount = poststacksize - firstreturn; } // Handle C++ errors thrown from C++ functions bound inside of lua - catch (const char* error) { + catch (const char* error) { h.stackindex = 0; stack::push(lua_state(), error); firstreturn = lua_gettop(lua_state()); diff --git a/sol/types.hpp b/sol/types.hpp index 158ba31c..be09c1fa 100644 --- a/sol/types.hpp +++ b/sol/types.hpp @@ -48,19 +48,19 @@ inline int static_trampoline (lua_State* L) { template inline int trampoline(lua_State* L, Fx&& f) { - try { - return f(L); - } - catch (const char *s) { // Catch and convert exceptions. - lua_pushstring(L, s); - } - catch (const std::exception& e) { - lua_pushstring(L, e.what()); - } - catch (...) { - lua_pushstring(L, "caught (...) exception"); - } - return lua_error(L); + try { + return f(L); + } + catch (const char *s) { // Catch and convert exceptions. + lua_pushstring(L, s); + } + catch (const std::exception& e) { + lua_pushstring(L, e.what()); + } + catch (...) { + lua_pushstring(L, "caught (...) exception"); + } + return lua_error(L); } inline int c_trampoline(lua_State* L, lua_CFunction f) { diff --git a/tests.cpp b/tests.cpp index 9b3b6bf9..8547810e 100644 --- a/tests.cpp +++ b/tests.cpp @@ -1201,16 +1201,16 @@ TEST_CASE( "functions/function_result-protected_function_result", "Function resu luadoom.error_handler = cpphandler; { - sol::protected_function_result result = doom(); - REQUIRE(!result.valid()); - std::string errorstring = result; - REQUIRE(errorstring == handlederrormessage); + sol::protected_function_result result = doom(); + REQUIRE(!result.valid()); + std::string errorstring = result; + REQUIRE(errorstring == handlederrormessage); } { - sol::protected_function_result result = luadoom(); - REQUIRE(!result.valid()); - std::string errorstring = result; - REQUIRE(errorstring == handlederrormessage); + sol::protected_function_result result = luadoom(); + REQUIRE(!result.valid()); + std::string errorstring = result; + REQUIRE(errorstring == handlederrormessage); } }