From 98fbbafef78057c818fb02b15c27e38ad2f5b5bc Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Tue, 28 Apr 2026 15:56:07 +0100 Subject: config/errors: Report and categorize errors properly for actions (#14192) Makes all errors categorized, some not displayed, some displayed. All errors can be obtained after hl.dispatch() --- src/config/lua/bindings/LuaBindingsInternal.hpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/config/lua/bindings/LuaBindingsInternal.hpp') diff --git a/src/config/lua/bindings/LuaBindingsInternal.hpp b/src/config/lua/bindings/LuaBindingsInternal.hpp index 2cd65184..fc07515f 100644 --- a/src/config/lua/bindings/LuaBindingsInternal.hpp +++ b/src/config/lua/bindings/LuaBindingsInternal.hpp @@ -127,7 +127,10 @@ namespace Config::Lua::Bindings::Internal { std::optional windowFromUpval(lua_State* L, int idx); void pushWindowUpval(lua_State* L, int tableIdx); - void checkResult(lua_State* L, const Config::Actions::ActionResult& r); + int checkResult(lua_State* L, const Config::Actions::ActionResult& r); + int pushSuccessResult(lua_State* L, const Config::Actions::SActionResult& r = {}); + int pushErrorResult(lua_State* L, const Config::Actions::SActionError& e); + void reportError(lua_State* L, const Config::Actions::SActionError& e); PHLWORKSPACE resolveWorkspaceStr(const std::string& args); PHLMONITOR resolveMonitorStr(const std::string& args); std::string getSourceInfo(lua_State* L, int stackLevel = 1); @@ -139,16 +142,24 @@ namespace Config::Lua::Bindings::Internal { std::expected ruleValueToString(lua_State* L); std::expected, int> buildRuleFromTable(lua_State* L, int idx); - int configError(lua_State* L, std::string s, int stackLevel = 1); + int configError(lua_State* L, std::string s, Config::Actions::eActionErrorLevel level = Config::Actions::eActionErrorLevel::ERROR, + Config::Actions::eActionErrorCode code = Config::Actions::eActionErrorCode::UNKNOWN, int stackLevel = 1); + int dispatcherError(lua_State* L, std::string s, Config::Actions::eActionErrorLevel level = Config::Actions::eActionErrorLevel::ERROR, + Config::Actions::eActionErrorCode code = Config::Actions::eActionErrorCode::UNKNOWN, int stackLevel = 1); template int configError(lua_State* L, std::format_string fmt, Args&&... args) { return configError(L, std::format(fmt, std::forward(args)...)); } + template + int dispatcherError(lua_State* L, Config::Actions::eActionErrorLevel level, Config::Actions::eActionErrorCode code, std::format_string fmt, Args&&... args) { + return dispatcherError(L, std::format(fmt, std::forward(args)...), level, code); + } + template int configError(lua_State* L, int stackLevel, std::format_string fmt, Args&&... args) { - return configError(L, std::format(fmt, std::forward(args)...), stackLevel); + return configError(L, std::format(fmt, std::forward(args)...), Config::Actions::eActionErrorLevel::ERROR, Config::Actions::eActionErrorCode::UNKNOWN, stackLevel); } template -- cgit v1.2.3