formatting

This commit is contained in:
ThePhD 2016-02-27 08:04:02 -05:00
parent 0113fb86b4
commit 4ed197f065
3 changed files with 22 additions and 22 deletions

View File

@ -170,7 +170,7 @@ private:
returncount = poststacksize - firstreturn; returncount = poststacksize - firstreturn;
} }
// Handle C++ errors thrown from C++ functions bound inside of lua // Handle C++ errors thrown from C++ functions bound inside of lua
catch (const char* error) { catch (const char* error) {
h.stackindex = 0; h.stackindex = 0;
stack::push(lua_state(), error); stack::push(lua_state(), error);
firstreturn = lua_gettop(lua_state()); firstreturn = lua_gettop(lua_state());

View File

@ -48,19 +48,19 @@ inline int static_trampoline (lua_State* L) {
template <typename Fx> template <typename Fx>
inline int trampoline(lua_State* L, Fx&& f) { inline int trampoline(lua_State* L, Fx&& f) {
try { try {
return f(L); return f(L);
} }
catch (const char *s) { // Catch and convert exceptions. catch (const char *s) { // Catch and convert exceptions.
lua_pushstring(L, s); lua_pushstring(L, s);
} }
catch (const std::exception& e) { catch (const std::exception& e) {
lua_pushstring(L, e.what()); lua_pushstring(L, e.what());
} }
catch (...) { catch (...) {
lua_pushstring(L, "caught (...) exception"); lua_pushstring(L, "caught (...) exception");
} }
return lua_error(L); return lua_error(L);
} }
inline int c_trampoline(lua_State* L, lua_CFunction f) { inline int c_trampoline(lua_State* L, lua_CFunction f) {

View File

@ -1201,16 +1201,16 @@ TEST_CASE( "functions/function_result-protected_function_result", "Function resu
luadoom.error_handler = cpphandler; luadoom.error_handler = cpphandler;
{ {
sol::protected_function_result result = doom(); sol::protected_function_result result = doom();
REQUIRE(!result.valid()); REQUIRE(!result.valid());
std::string errorstring = result; std::string errorstring = result;
REQUIRE(errorstring == handlederrormessage); REQUIRE(errorstring == handlederrormessage);
} }
{ {
sol::protected_function_result result = luadoom(); sol::protected_function_result result = luadoom();
REQUIRE(!result.valid()); REQUIRE(!result.valid());
std::string errorstring = result; std::string errorstring = result;
REQUIRE(errorstring == handlederrormessage); REQUIRE(errorstring == handlederrormessage);
} }
} }