diff --git a/src/logic/scripting/lua/LuaState.cpp b/src/logic/scripting/lua/LuaState.cpp index e5ff51fc..32223c7b 100644 --- a/src/logic/scripting/lua/LuaState.cpp +++ b/src/logic/scripting/lua/LuaState.cpp @@ -356,7 +356,7 @@ dynamic::Value lua::LuaState::tovalue(int idx) { } default: throw std::runtime_error( - "lua type "+std::to_string(type)+" is not supported" + "lua type "+std::string(luaL_typename(L, type))+" is not supported" ); } } diff --git a/src/logic/scripting/lua/libconsole.cpp b/src/logic/scripting/lua/libconsole.cpp index 104b6078..bab7c43e 100644 --- a/src/logic/scripting/lua/libconsole.cpp +++ b/src/logic/scripting/lua/libconsole.cpp @@ -14,6 +14,9 @@ namespace scripting { using namespace scripting; static int l_add_command(lua_State* L) { + if (!lua_isstring(L, 1) || !lua_isstring(L, 2) || !lua_isfunction(L, 3)) { + throw std::runtime_error("invalid argument type"); + } auto scheme = lua_tostring(L, 1); auto description = lua_tostring(L, 2); lua_pushvalue(L, 3); @@ -25,7 +28,7 @@ static int l_add_command(lua_State* L) { } ); } catch (const parsing_error& err) { - luaL_error(L, ("command scheme error:\n"+err.errorLog()).c_str()); + throw std::runtime_error(("command scheme error:\n"+err.errorLog()).c_str()); } return 0; } diff --git a/src/logic/scripting/lua/lua_commons.hpp b/src/logic/scripting/lua/lua_commons.hpp index 84772d38..38d17ebc 100644 --- a/src/logic/scripting/lua/lua_commons.hpp +++ b/src/logic/scripting/lua/lua_commons.hpp @@ -7,6 +7,7 @@ #else #include #endif +#include #include namespace lua {