diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-04-28 15:56:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-28 15:56:07 +0100 |
| commit | 98fbbafef78057c818fb02b15c27e38ad2f5b5bc (patch) | |
| tree | c62aa1eae704e7595d58f7edeb3804e8bfd0099d /src/config/lua/bindings/LuaBindingsInternal.hpp | |
| parent | d4c6ff434c5c7aa66bc7c28e5ce336d2a694bfcc (diff) | |
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()
Diffstat (limited to 'src/config/lua/bindings/LuaBindingsInternal.hpp')
| -rw-r--r-- | src/config/lua/bindings/LuaBindingsInternal.hpp | 17 |
1 files changed, 14 insertions, 3 deletions
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<PHLWINDOW> 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,7 +142,10 @@ namespace Config::Lua::Bindings::Internal { std::expected<std::string, std::string> ruleValueToString(lua_State* L); std::expected<SP<Desktop::Rule::CWindowRule>, 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 <typename... Args> int configError(lua_State* L, std::format_string<Args...> fmt, Args&&... args) { @@ -147,8 +153,13 @@ namespace Config::Lua::Bindings::Internal { } template <typename... Args> + int dispatcherError(lua_State* L, Config::Actions::eActionErrorLevel level, Config::Actions::eActionErrorCode code, std::format_string<Args...> fmt, Args&&... args) { + return dispatcherError(L, std::format(fmt, std::forward<Args>(args)...), level, code); + } + + template <typename... Args> int configError(lua_State* L, int stackLevel, std::format_string<Args...> fmt, Args&&... args) { - return configError(L, std::format(fmt, std::forward<Args>(args)...), stackLevel); + return configError(L, std::format(fmt, std::forward<Args>(args)...), Config::Actions::eActionErrorLevel::ERROR, Config::Actions::eActionErrorCode::UNKNOWN, stackLevel); } template <typename T, size_t N> |
