mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 00:03:50 +00:00
fix: display Lua errors from OnUpdate, executeFile, executeString as UI errors
Extend the Lua error UI display to cover all error paths: - OnUpdate frame callbacks (previously only logged) - executeFile loading errors (now also shown as UI error) - executeString /run errors (now also shown as UI error) This ensures addon developers see ALL Lua errors in-game, not just event handler errors from the previous commit.
This commit is contained in:
parent
900626f5fe
commit
6687c617d9
1 changed files with 6 additions and 1 deletions
|
|
@ -3891,7 +3891,10 @@ void LuaEngine::dispatchOnUpdate(float elapsed) {
|
||||||
lua_pushvalue(L_, -3); // self (frame)
|
lua_pushvalue(L_, -3); // self (frame)
|
||||||
lua_pushnumber(L_, static_cast<double>(elapsed));
|
lua_pushnumber(L_, static_cast<double>(elapsed));
|
||||||
if (lua_pcall(L_, 2, 0, 0) != 0) {
|
if (lua_pcall(L_, 2, 0, 0) != 0) {
|
||||||
LOG_ERROR("LuaEngine: OnUpdate error: ", lua_tostring(L_, -1));
|
const char* uerr = lua_tostring(L_, -1);
|
||||||
|
std::string uerrStr = uerr ? uerr : "(unknown)";
|
||||||
|
LOG_ERROR("LuaEngine: OnUpdate error: ", uerrStr);
|
||||||
|
if (luaErrorCallback_) luaErrorCallback_(uerrStr);
|
||||||
lua_pop(L_, 1);
|
lua_pop(L_, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -4098,6 +4101,7 @@ bool LuaEngine::executeFile(const std::string& path) {
|
||||||
const char* errMsg = lua_tostring(L_, -1);
|
const char* errMsg = lua_tostring(L_, -1);
|
||||||
std::string msg = errMsg ? errMsg : "(unknown error)";
|
std::string msg = errMsg ? errMsg : "(unknown error)";
|
||||||
LOG_ERROR("LuaEngine: error loading '", path, "': ", msg);
|
LOG_ERROR("LuaEngine: error loading '", path, "': ", msg);
|
||||||
|
if (luaErrorCallback_) luaErrorCallback_(msg);
|
||||||
if (gameHandler_) {
|
if (gameHandler_) {
|
||||||
game::MessageChatData errChat;
|
game::MessageChatData errChat;
|
||||||
errChat.type = game::ChatType::SYSTEM;
|
errChat.type = game::ChatType::SYSTEM;
|
||||||
|
|
@ -4119,6 +4123,7 @@ bool LuaEngine::executeString(const std::string& code) {
|
||||||
const char* errMsg = lua_tostring(L_, -1);
|
const char* errMsg = lua_tostring(L_, -1);
|
||||||
std::string msg = errMsg ? errMsg : "(unknown error)";
|
std::string msg = errMsg ? errMsg : "(unknown error)";
|
||||||
LOG_ERROR("LuaEngine: script error: ", msg);
|
LOG_ERROR("LuaEngine: script error: ", msg);
|
||||||
|
if (luaErrorCallback_) luaErrorCallback_(msg);
|
||||||
if (gameHandler_) {
|
if (gameHandler_) {
|
||||||
game::MessageChatData errChat;
|
game::MessageChatData errChat;
|
||||||
errChat.type = game::ChatType::SYSTEM;
|
errChat.type = game::ChatType::SYSTEM;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue