mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
formatting
This commit is contained in:
parent
0113fb86b4
commit
4ed197f065
|
@ -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());
|
||||
|
|
|
@ -48,19 +48,19 @@ inline int static_trampoline (lua_State* L) {
|
|||
|
||||
template <typename Fx>
|
||||
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) {
|
||||
|
|
16
tests.cpp
16
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user