Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Foundation::Execution::Exception< BASE_EXCEPTION > Class Template Reference

Exception<> is a replacement (subclass) for any std c++ exception class (e.g. the default 'std::exception'), which adds UNICODE String support. More...

#include <Exceptions.h>

Inheritance diagram for Stroika::Foundation::Execution::Exception< BASE_EXCEPTION >:
Stroika::Foundation::Execution::ExceptionStringHelper Stroika::Foundation::Execution::SystemErrorException< filesystem_error > Stroika::Foundation::Execution::RuntimeErrorException< BASE_EXCEPTION > Stroika::Foundation::Execution::SystemErrorException< BASE_EXCEPTION > Stroika::Foundation::IO::FileSystem::Exception Stroika::Foundation::Characters::CharacterEncodingException Stroika::Foundation::DataExchange::BadFormatException Stroika::Foundation::DataExchange::InternetMediaTypeNotSupportedException Stroika::Foundation::DataExchange::XML::DOM::XPath::XPathExpressionNotSupported Stroika::Foundation::Database::Exception Stroika::Foundation::Execution::FeatureNotSupportedException Stroika::Foundation::Execution::InvalidCommandLineArgument Stroika::Foundation::Execution::NestedException Stroika::Foundation::Execution::OperationNotSupportedException Stroika::Foundation::Execution::ProcessRunner::Exception Stroika::Foundation::IO::Network::HTTP::Exception Stroika::Foundation::IO::Network::InternetProtocol::ICMP::V4::DestinationUnreachableException Stroika::Foundation::IO::Network::InternetProtocol::ICMP::V4::TTLExpiredException Stroika::Foundation::Streams::EOFException Stroika::Foundation::Streams::EWouldBlock Stroika::Foundation::Execution::TimeOutException

Public Member Functions

virtual const char * what () const noexcept override
 
- Public Member Functions inherited from Stroika::Foundation::Execution::ExceptionStringHelper
 ExceptionStringHelper ()=delete
 
nonvirtual Characters::String GetBasicErrorMessage () const
 
nonvirtual Characters::String GetFullErrorMessage () const
 
nonvirtual Containers::Stack< Activity<> > GetActivities () const
 
template<typename T >
nonvirtual T As () const
 

Protected Member Functions

template<typename... BASE_EXCEPTION_ARGS>
 Exception (const Characters::String &reasonForError, BASE_EXCEPTION_ARGS... baseExceptionArgs)
 
- Protected Member Functions inherited from Stroika::Foundation::Execution::ExceptionStringHelper
nonvirtual const char * _PeekAtNarrowSDKString_ () const
 

Detailed Description

template<typename BASE_EXCEPTION = exception>
class Stroika::Foundation::Execution::Exception< BASE_EXCEPTION >

Exception<> is a replacement (subclass) for any std c++ exception class (e.g. the default 'std::exception'), which adds UNICODE String support.

Stroika's Exception<> class is fully interoperable with the normal C++ exception classes, but its use offers two benefits: o It guarantees that UNICODE messages (including things like filenames) are properly preserved in the exception message, even if the system default code page (locale) does not allow representing those characters.

o It integrates neatly with the Stroika 'Activity' mechanism, whereby you declare current 'activities' on the stack and these are automatically integrated into exceptions to provide clearer messages (e.g. instead of getting the error message o "(errno: 13)" OR o "Permission denied" Stroika returns something like: o "Permission denied {errno: 13} while binding to INADDR_ANY:80, while constructing static content webserver."

See also
Activity<>
DeclareActivity
Example Usage
static constexpr Activity kBuildingThingy_ {"building thingy"sv };
try {
DeclareActivity declareActivity { &kBuildingThingy_ };
doBuildThing (); // throw any exception (that inherits from Exception<>)
}
catch (...) {
String exceptionMsg = Characters::ToString (current_exception ());
Assert (exceptionMsg.Contains (kBuildingThingy_.AsString ()); // exception e while building thingy...
}
String ToString(T &&t, ARGS... args)
Return a debug-friendly, display version of the argument: not guaranteed parsable or usable except fo...
Definition ToString.inl:465

Definition at line 157 of file Exceptions.h.

Constructor & Destructor Documentation

◆ Exception()

template<typename BASE_EXCEPTION >
template<typename... BASE_EXCEPTION_ARGS>
Stroika::Foundation::Execution::Exception< BASE_EXCEPTION >::Exception ( const Characters::String reasonForError,
BASE_EXCEPTION_ARGS...  baseExceptionArgs 
)
explicitprotected

For BASE_EXCEPTION classes with constructors OTHER than just 'message' - you cannot use a 'using X = Exception(x)' but a subclass which uses this delegating method.

Definition at line 71 of file Exceptions.inl.

Member Function Documentation

◆ what()

template<typename BASE_EXCEPTION >
const char * Stroika::Foundation::Execution::Exception< BASE_EXCEPTION >::what ( ) const
overridevirtualnoexcept

Provide a 'c string' variant of the exception message. Convert the UNICODE string argument to a narrow-string (multibyte) in the current locale encoding.

Definition at line 77 of file Exceptions.inl.


The documentation for this class was generated from the following files: