13 class ExceptionStringHelper;
15 bool ShouldImbueActivities_ (
const ExceptionStringHelper& e)
noexcept;
16 void ImbueCurrentActivities_ (ExceptionStringHelper* e);
21#if qStroika_Foundation_Execution_Throw_TraceThrowpointBacktrace
25 string ToString_ (
const type_info&);
27 inline string ToString_ (
const T& t)
29 if constexpr (is_convertible_v<T, const exception&>) {
33 return ToString_ (
typeid (T));
37#if qStroika_Foundation_Debug_DefaultTracingOn
38 void JustDbgTrace_ (
const string& msg);
39 void JustDbgTrace_ (
const wstring& msg);
40 void ThrowingExceptionDbgTrace_ (
const string& msg);
41 void ThrowingExceptionDbgTrace_ (
const wstring& msg);
42 void ReThrowingExceptionDbgTrace_ (
const string& msg);
43 void ReThrowingExceptionDbgTrace_ (
const wstring& msg = {});
54 [[noreturn]]
inline void Throw (T&& e2Throw)
56 static_assert (is_convertible_v<remove_cvref_t<T>*, exception*>);
59 if (Private_::ShouldImbueActivities_ (e2Throw)) [[unlikely]] {
60 remove_cvref_t<T> tmp = e2Throw;
61 Private_::ImbueCurrentActivities_ (&tmp);
62#if qStroika_Foundation_Debug_DefaultTracingOn
63 Private_::ThrowingExceptionDbgTrace_ (Private_::ToString_ (tmp));
68#if qStroika_Foundation_Debug_DefaultTracingOn
69 Private_::ThrowingExceptionDbgTrace_ (Private_::ToString_ (forward<T> (e2Throw)));
74 [[noreturn]]
inline void Throw (T&& e2Throw, [[maybe_unused]]
const char* traceMsg)
76 static_assert (is_convertible_v<remove_cvref_t<T>*, exception*>);
77#if qStroika_Foundation_Debug_DefaultTracingOn
78 Private_::JustDbgTrace_ (traceMsg);
85 Throw (forward<T> (e2Throw));
88 [[noreturn]]
inline void Throw (T&& e2Throw, [[maybe_unused]]
const wchar_t* traceMsg)
90 static_assert (is_convertible_v<remove_cvref_t<T>*, exception*>);
91#if qStroika_Foundation_Debug_DefaultTracingOn
92 Private_::JustDbgTrace_ (traceMsg);
99 Throw (forward<T> (e2Throw));
109#if qStroika_Foundation_Debug_DefaultTracingOn
110 Private_::ReThrowingExceptionDbgTrace_ ();
114 [[noreturn]]
inline void ReThrow (
const exception_ptr& e)
116#if qStroika_Foundation_Debug_DefaultTracingOn
117 Private_::ReThrowingExceptionDbgTrace_ ();
119 rethrow_exception (e);
121 [[noreturn]]
inline void ReThrow ([[maybe_unused]]
const char* traceMsg)
123#if qStroika_Foundation_Debug_DefaultTracingOn
124 Private_::ReThrowingExceptionDbgTrace_ (traceMsg);
128 [[noreturn]]
inline void ReThrow (
const exception_ptr& e, [[maybe_unused]]
const char* traceMsg)
130#if qStroika_Foundation_Debug_DefaultTracingOn
131 Private_::ReThrowingExceptionDbgTrace_ (traceMsg);
133 rethrow_exception (e);
135 [[noreturn]]
inline void ReThrow ([[maybe_unused]]
const wchar_t* traceMsg)
137#if qStroika_Foundation_Debug_DefaultTracingOn
138 Private_::ReThrowingExceptionDbgTrace_ (traceMsg);
142 [[noreturn]]
inline void ReThrow (
const exception_ptr& e, [[maybe_unused]]
const wchar_t* traceMsg)
144#if qStroika_Foundation_Debug_DefaultTracingOn
145 Private_::ReThrowingExceptionDbgTrace_ (traceMsg);
147 rethrow_exception (e);
155 template <equality_comparable_with<
nullptr_t> T,
typename E>
158 if (p ==
nullptr) [[unlikely]] {
159 Throw (e,
"ThrowIfNull (nullptr) - throwing bad_alloc");
162 template <equality_comparable_with<
nullptr_t> T>
165 static const bad_alloc kException_;
168 template <Common::Weak_Equality_Comparable_With<nullopt_t> T,
typename E>
170 requires (not equality_comparable_with<nullptr_t, T>)
172 if (p == nullopt) [[unlikely]] {
173 Throw (e,
"ThrowIfNull (nullopt) - throwing bad_optional_access");
176 template <Common::Weak_Equality_Comparable_With<nullopt_t> T>
178 requires (not equality_comparable_with<nullptr_t, T>)
180 static const bad_optional_access kException_;
189 template <
typename EXPECTED>
190 inline auto ThrowIfFailed (
const EXPECTED& e) ->
typename EXPECTED::value_type
void Throw(T &&e2Throw)
like the builtin C++ 'throw', but stamps in the current Activity context and does helpful,...
void ThrowIfNull(const Private_::ConstVoidStar &p, const HRESULT &hr)
Template specialization for ThrowIfNull (), for thing being thrown HRESULT - really throw HRESULTErro...
EXPECTED::value_type ThrowIfFailed(const EXPECTED &e)