mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Pop errors off the stack if they're present.
This commit is contained in:
parent
5193db55c3
commit
f896a9ea16
@ -37,6 +37,7 @@ namespace sol {
|
||||
std::string w;
|
||||
public:
|
||||
error(const std::string& str) : error(detail::direct_error, "lua: error: " + str) {}
|
||||
error(std::string&& str) : error(detail::direct_error, "lua: error: " + std::move(str)) {}
|
||||
error(detail::direct_error_tag, const std::string& str) : std::runtime_error(""), w(str) {}
|
||||
error(detail::direct_error_tag, std::string&& str) : std::runtime_error(""), w(std::move(str)) {}
|
||||
|
||||
|
@ -31,8 +31,12 @@ namespace sol {
|
||||
return -1;
|
||||
#else
|
||||
const char* message = lua_tostring(L, -1);
|
||||
std::string err = message ? message : "An unexpected error occurred and forced the lua state to call atpanic";
|
||||
throw error(err);
|
||||
if (message) {
|
||||
std::string err = message;
|
||||
lua_pop(L, 1);
|
||||
throw error(err);
|
||||
}
|
||||
throw error(std::string("An unexpected error occurred and forced the lua state to call atpanic"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user