From 33ac753452582ca7a96e324182dbd37528dfc5c7 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 8 Jul 2020 19:26:52 +0300 Subject: [PATCH] [base] Returns void case for all kinds of exceptions catcher. --- base/exception.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/base/exception.hpp b/base/exception.hpp index 8e189fea42..d29358cefb 100644 --- a/base/exception.hpp +++ b/base/exception.hpp @@ -28,9 +28,11 @@ template std::result_of_t ExceptionCatcher(std::string const & comment, Fn && fn, Args &&... args) noexcept { + bool constexpr isVoidReturned = std::is_same, void>::value; try { - return std::forward(fn)(std::forward(args)...); + if constexpr (!isVoidReturned) + return std::forward(fn)(std::forward(args)...); } catch (RootException const & ex) { @@ -44,7 +46,9 @@ std::result_of_t ExceptionCatcher(std::string const & comme { LOG(LWARNING, ("Unknown exception.", comment)); } - return {}; + + if constexpr (!isVoidReturned) + return {}; } #define DECLARE_EXCEPTION(exception_name, base_exception) \