Added walkExceptionCause helper function.
This commit is contained in:
parent
aa804a2a99
commit
48aeb32ee5
@ -48,5 +48,30 @@ inline decltype(auto) ensure(TCondition&& condition, TExceptionArgs&&... args)
|
|||||||
}
|
}
|
||||||
return std::forward<TCondition>(condition);
|
return std::forward<TCondition>(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename TFunc>
|
||||||
|
void walkExceptionCause(const std::exception_ptr& cause, TFunc func)
|
||||||
|
{
|
||||||
|
if (cause)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::rethrow_exception(cause);
|
||||||
|
}
|
||||||
|
catch(Exception& exc)
|
||||||
|
{
|
||||||
|
func(exc);
|
||||||
|
walkExceptionCause(exc.getCause(), std::move(func));
|
||||||
|
}
|
||||||
|
catch(std::exception& exc)
|
||||||
|
{
|
||||||
|
func(exc);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
func(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace mijin
|
} // namespace mijin
|
||||||
#endif // MIJIN_UTIL_EXCEPTION_HPP_INCLUDED
|
#endif // MIJIN_UTIL_EXCEPTION_HPP_INCLUDED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user