diff --git a/inc/basic_widgets/core/error_helper.hpp b/inc/basic_widgets/core/error_helper.hpp index 1cbfebb..bf1e91a 100644 --- a/inc/basic_widgets/core/error_helper.hpp +++ b/inc/basic_widgets/core/error_helper.hpp @@ -7,10 +7,10 @@ namespace bwidgets { template - inline auto ptr_or_throw(T* ptr, const std::string& w = "") -> T* + inline auto ptr_or_throw(T* ptr, const std::string& w = "unknown") -> T* { std::string what; - if constexpr (std::is_same_v) what = w.empty() ? SDL_GetError() : w; + if constexpr (std::is_same_v) what = w == "unknown" ? SDL_GetError() : w; else what = w; if (ptr == nullptr) throw E(what); @@ -19,14 +19,14 @@ namespace bwidgets template inline auto success_or_throw( - T code, const std::string& w = "", + T code, const std::string& w = "unknown", std::function success = [](T code) { return code == 0; }) -> T { - std::string what {w.empty() ? SDL_GetError() : w}; + std::string what {w == "unknown" ? SDL_GetError() : w}; if constexpr (std::is_same_v) { if (code <= 0) throw E(what); } - else if (!success(code)) throw E(what); + else if (success(code)) throw E(what); return code; }