10 namespace Private_::SystemErrorExceptionPrivate_ {
11 Characters::String mkMsg_ (error_code errCode);
12 Characters::String mkCombinedMsg_ (error_code errCode,
const Characters::String& message);
13 void TranslateException_ (error_code errCode);
14 unique_ptr<exception> TranslateExceptionQuietly_ (error_code errCode);
33 return fRawErrorMessage_;
37 return fFullErrorMessage_;
44 inline wstring ExceptionStringHelper::As ()
const
46 return fFullErrorMessage_.
As<wstring> ();
51 return fFullErrorMessage_;
53 inline const char* ExceptionStringHelper::_PeekAtNarrowSDKString_ ()
const
55 return fSDKCharString_.
c_str ();
63 template <
typename BASE_EXCEPTION>
69 template <
typename BASE_EXCEPTION>
70 template <
typename... BASE_EXCEPTION_ARGS>
73 , inherited{forward<BASE_EXCEPTION_ARGS> (baseExceptionArgs)...}
76 template <
typename BASE_EXCEPTION>
79 return _PeekAtNarrowSDKString_ ();
87 template <
typename BASE_EXCEPTION>
98 inline NestedException::NestedException (
const Characters::String& msg,
const exception_ptr& basedOnException)
99 : RuntimeErrorException<>{
102 , fBasedOnException{basedOnException}
111 template <
typename BASE_EXCEPTION>
112 inline SystemErrorException<BASE_EXCEPTION>::SystemErrorException (error_code errCode)
113 : SystemErrorException{errCode, Private_::SystemErrorExceptionPrivate_::mkMsg_ (errCode)}
116 template <
typename BASE_EXCEPTION>
117 inline SystemErrorException<BASE_EXCEPTION>::SystemErrorException (error_code errCode,
const Characters::String& message)
118 : inherited{Private_::SystemErrorExceptionPrivate_::mkCombinedMsg_ (errCode, message), errCode}
121 template <
typename BASE_EXCEPTION>
122 inline SystemErrorException<BASE_EXCEPTION>::SystemErrorException (
int ev,
const std::error_category& ecat)
123 : SystemErrorException{error_code{ev, ecat}}
126 template <
typename BASE_EXCEPTION>
127 inline SystemErrorException<BASE_EXCEPTION>::SystemErrorException (
int ev,
const std::error_category& ecat,
const Characters::String& message)
128 : SystemErrorException{error_code{ev, ecat}, message}
131 template <
typename BASE_EXCEPTION>
132 template <
typename... BASE_EXCEPTION_ARGS>
134 :
inherited{reasonForError, forward<BASE_EXCEPTION_ARGS> (baseExceptionArgs)...}
145#if Stroia_Foundation_Execution_Exceptions_USE_NOISY_TRACE_IN_THIS_MODULE_
146 TraceContenxtBumper tctx{
"Execution::ThrowPOSIXErrNo",
"{}"_f, errNo};
148 Require (errNo != 0);
149#if qStroika_Foundation_Common_Platform_POSIX
150 error_code ec{errNo, system_category ()};
152 error_code ec{errNo, generic_category ()};
154 Private_::SystemErrorExceptionPrivate_::TranslateException_ (ec);
163 template <
typename INT_TYPE>
166 if (returnCode < 0) [[unlikely]] {
177 inline void ThrowSystemErrNo (
int sysErr)
179#if Stroia_Foundation_Execution_Exceptions_USE_NOISY_TRACE_IN_THIS_MODULE_
180 TraceContenxtBumper tctx{
"Execution::ThrowSystemErrNo",
"{}"_f, sysErr};
182 Require (sysErr != 0);
183 error_code ec{sysErr, system_category ()};
184 Private_::SystemErrorExceptionPrivate_::TranslateException_ (ec);
187#if qStroika_Foundation_Common_Platform_POSIX or qStroika_Foundation_Common_Platform_Windows
188 [[noreturn]]
inline void ThrowSystemErrNo ()
190#if qStroika_Foundation_Common_Platform_POSIX
191 ThrowSystemErrNo (errno);
192#elif qStroika_Foundation_Common_Platform_Windows
193 ThrowSystemErrNo (::GetLastError ());
203 template <
typename CALL>
206 decltype (call ()) ret;
210 }
while (ret < 0 and errno == EINTR);
221 if (returnValue ==
nullptr) [[unlikely]] {
231 template <
typename F>
String is like std::u32string, except it is much easier to use, often much more space efficient,...
nonvirtual tuple< const wchar_t *, wstring_view > c_str(Memory::StackBuffer< wchar_t > *possibleBackingStore) const
Exception<> is a replacement (subclass) for any std c++ exception class (e.g. the default 'std::excep...
virtual const char * what() const noexcept override
ExceptionStringHelper()=delete
nonvirtual CONTAINER_OF_T As(CONTAINER_OF_T_CONSTRUCTOR_ARGS... args) const
void CheckForInterruption()
void Throw(T &&e2Throw)
identical to builtin C++ 'throw' except that it does helpful, type dependent DbgTrace() messages firs...
void ThrowPOSIXErrNo(errno_t errNo=errno)
treats errNo as a POSIX errno value, and throws a SystemError (subclass of @std::system_error) except...
auto Handle_ErrNoResultInterruption(CALL call) -> decltype(call())
Handle UNIX EINTR system call behavior - fairly transparently - just effectively removes them from th...
void ThrowPOSIXErrNoIfNull(void *returnValue)
auto TranslateExceptionToOptional(F &&f) -> optional< remove_cvref_t< invoke_result_t< F > > >
Containers::Stack< Activity<> > CaptureCurrentActivities()
Returns a copyable preservable version of the current activities stack.
INT_TYPE ThrowPOSIXErrNoIfNegative(INT_TYPE returnCode)