8#if Stroika_Foundation_Execution_Exceptions_USE_NOISY_TRACE_IN_THIS_MODULE_
15 namespace Private_::SystemErrorExceptionPrivate_ {
16 Characters::String mkMsg_ (error_code errCode);
17 Characters::String mkCombinedMsg_ (error_code errCode,
const Characters::String& message);
24 void ThrowTranslatedExceptionIfNeeded_ (error_code errCode,
const Characters::String* message =
nullptr);
39 return fRawErrorMessage_;
44 return fFullErrorMessage_;
54 return fFullErrorMessage_.
As<wstring> ();
60 return fFullErrorMessage_;
65 return fSDKCharString_.c_str ();
73 template <derived_from<exception> BASE_EXCEPTION>
75 requires (default_initializable<BASE_EXCEPTION>)
80 template <derived_from<exception> BASE_EXCEPTION>
82 requires (not default_initializable<BASE_EXCEPTION> and constructible_from<BASE_EXCEPTION, const char*>)
83 : ExceptionStringHelper{reasonForError}
87 template <derived_from<exception> BASE_EXCEPTION>
88 template <
typename... BASE_EXCEPTION_ARGS>
91 , inherited{forward<BASE_EXCEPTION_ARGS> (baseExceptionArgs)...}
94 template <derived_from<exception> BASE_EXCEPTION>
97 return _PeekAtNarrowSDKString ();
111 template <derived_from<exception> BASE_EXCEPTION = runtime_error>
112 class [[deprecated (
"Since Stroika v3.0d25 - use Execution::Exception<runtime_error>")]] RuntimeErrorException
126 inline NestedException::NestedException (
const Characters::String& msg,
const exception_ptr& basedOnException)
127 : Execution::Exception<runtime_error>{
msg}
128 , fBasedOnException{basedOnException}
137 inline SystemErrorException::SystemErrorException (error_code errCode)
138 : SystemErrorException{errCode, Private_::SystemErrorExceptionPrivate_::mkMsg_ (errCode)}
141 inline SystemErrorException::SystemErrorException (error_code errCode,
const Characters::String& message)
142 : inherited{Private_::SystemErrorExceptionPrivate_::mkCombinedMsg_ (errCode, message), errCode}
145 inline SystemErrorException::SystemErrorException (
int ev,
const std::error_category& ecat)
146 : SystemErrorException{error_code{ev, ecat}}
149 inline SystemErrorException::SystemErrorException (
int ev,
const std::error_category& ecat,
const Characters::String& message)
150 : SystemErrorException{error_code{ev, ecat}, message}
161#if Stroika_Foundation_Execution_Exceptions_USE_NOISY_TRACE_IN_THIS_MODULE_
162 using namespace Characters::Literals;
165 Require (errNo != 0);
166#if qStroika_Platform_POSIX
167 error_code ec{errNo, system_category ()};
169 error_code ec{errNo, generic_category ()};
179 template <
typename INT_TYPE>
182 if (returnCode < 0) [[unlikely]] {
193 inline void ThrowSystemErrNo (
int sysErr)
195#if Stroika_Foundation_Execution_Exceptions_USE_NOISY_TRACE_IN_THIS_MODULE_
196 using namespace Characters::Literals;
199 Require (sysErr != 0);
200#if qStroika_Platform_Windows
201 ThrowError (error_code{sysErr, Platform::Windows::Win32_error_category ()});
203 ThrowError (error_code{sysErr, system_category ()});
214 Require (ec != error_code{});
215 Private_::SystemErrorExceptionPrivate_::ThrowTranslatedExceptionIfNeeded_ (ec);
220 Require (ec != error_code{});
221 Private_::SystemErrorExceptionPrivate_::ThrowTranslatedExceptionIfNeeded_ (ec, &message);
222 Throw (SystemErrorException{ec, message});
226 Require (ec != errc{});
229 [[noreturn]]
inline void ThrowError (errc ec,
const Characters::String& message)
231 Require (ec != errc{});
240#if qStroika_Platform_POSIX or qStroika_Platform_Windows
241 [[noreturn]]
inline void ThrowSystemErrNo ()
243#if qStroika_Platform_POSIX
244 ThrowSystemErrNo (errno);
245#elif qStroika_Platform_Windows
246 ThrowSystemErrNo (::GetLastError ());
256 template <
typename CALL>
259 decltype (call ()) ret;
263 }
while (ret < 0 and errno == EINTR);
274 if (returnValue ==
nullptr) [[unlikely]] {
284 template <
typename F>
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Exception<> is a replacement (subclass) for any std c++ exception class (e.g. the default 'std::excep...
Exception()=delete
construct with just a message - BASE_EXCEPTION gets whatever it minimally needs.
virtual const char * what() const noexcept override
nonvirtual optional< Containers::Stack< Activity<> > > GetActivities() const
nonvirtual Characters::String GetBasicErrorMessage() const
nonvirtual Characters::String GetFullErrorMessage() const
nonvirtual const char * _PeekAtNarrowSDKString() const
void CheckForInterruption()
void Throw(T &&e2Throw)
like the builtin C++ 'throw', but stamps in the current Activity context and does helpful,...
void ThrowPOSIXErrNo(errno_t errNo=errno)
treats argument errNo as a POSIX errno value, and calls ThrowError () with an error_code constructed ...
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 > > >
void ThrowError(error_code ec)
throw a SystemErrorException with the given error_code - or std::bad_alloc for errc::not_enough_memor...
INT_TYPE ThrowPOSIXErrNoIfNegative(INT_TYPE returnCode)