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<>{msg, }
100 , fBasedOnException{basedOnException}
109 template <
typename BASE_EXCEPTION>
110 inline SystemErrorException<BASE_EXCEPTION>::SystemErrorException (error_code errCode)
111 : SystemErrorException{errCode, Private_::SystemErrorExceptionPrivate_::mkMsg_ (errCode)}
114 template <
typename BASE_EXCEPTION>
115 inline SystemErrorException<BASE_EXCEPTION>::SystemErrorException (error_code errCode,
const Characters::String& message)
116 : inherited{Private_::SystemErrorExceptionPrivate_::mkCombinedMsg_ (errCode, message), errCode}
119 template <
typename BASE_EXCEPTION>
120 inline SystemErrorException<BASE_EXCEPTION>::SystemErrorException (
int ev,
const std::error_category& ecat)
121 : SystemErrorException{error_code{ev, ecat}}
124 template <
typename BASE_EXCEPTION>
125 inline SystemErrorException<BASE_EXCEPTION>::SystemErrorException (
int ev,
const std::error_category& ecat,
const Characters::String& message)
126 : SystemErrorException{error_code{ev, ecat}, message}
129 template <
typename BASE_EXCEPTION>
130 template <
typename... BASE_EXCEPTION_ARGS>
132 :
inherited{reasonForError, forward<BASE_EXCEPTION_ARGS> (baseExceptionArgs)...}
143#if Stroia_Foundation_Execution_Exceptions_USE_NOISY_TRACE_IN_THIS_MODULE_
144 TraceContenxtBumper tctx{
"Execution::ThrowPOSIXErrNo",
"{}"_f, errNo};
146 Require (errNo != 0);
147#if qStroika_Foundation_Common_Platform_POSIX
148 error_code ec{errNo, system_category ()};
150 error_code ec{errNo, generic_category ()};
152 Private_::SystemErrorExceptionPrivate_::TranslateException_ (ec);
161 template <
typename INT_TYPE>
164 if (returnCode < 0) [[unlikely]] {
175 inline void ThrowSystemErrNo (
int sysErr)
177#if Stroia_Foundation_Execution_Exceptions_USE_NOISY_TRACE_IN_THIS_MODULE_
178 TraceContenxtBumper tctx{
"Execution::ThrowSystemErrNo",
"{}"_f, sysErr};
180 Require (sysErr != 0);
181 error_code ec{sysErr, system_category ()};
182 Private_::SystemErrorExceptionPrivate_::TranslateException_ (ec);
183 Throw (SystemErrorException{ec});
185#if qStroika_Foundation_Common_Platform_POSIX or qStroika_Foundation_Common_Platform_Windows
186 [[noreturn]]
inline void ThrowSystemErrNo ()
188#if qStroika_Foundation_Common_Platform_POSIX
189 ThrowSystemErrNo (errno);
190#elif qStroika_Foundation_Common_Platform_Windows
191 ThrowSystemErrNo (::GetLastError ());
201 template <
typename CALL>
204 decltype (call ()) ret;
208 }
while (ret < 0 and errno == EINTR);
219 if (returnValue ==
nullptr) [[unlikely]] {
229 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)