Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
Stroika::Foundation::Execution::ExceptionStringHelper Class Reference

#include <Exceptions.h>

Inheritance diagram for Stroika::Foundation::Execution::ExceptionStringHelper:
Stroika::Foundation::Execution::Exception< runtime_error > Stroika::Foundation::Execution::Exception< system_error > Stroika::Foundation::Execution::Exception< filesystem_error > Stroika::Foundation::Execution::Exception< BASE_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::Execution::RequiredComponentMissingException 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::Frameworks::UPnP::SOAP::ActionException Stroika::Frameworks::WebService::SOAP::FaultException Stroika::Foundation::Execution::SystemErrorException Stroika::Foundation::IO::FileSystem::Exception

Public Member Functions

 ExceptionStringHelper ()=delete
 activities default to NULLOPT - meaning "not specified" - which is different from "specified, and there were none".
 
nonvirtual Characters::String GetBasicErrorMessage () const
 
nonvirtual Characters::String GetFullErrorMessage () const
 
nonvirtual optional< Containers::Stack< Activity<> > > GetActivities () const
 
nonvirtual void ImbueActivities (const optional< Containers::Stack< Activity<> > > &activities)
 Set, replace, or clear the activity stack. Any already-computed message text is discarded, since it depends on these.
 
template<typename T >
nonvirtual T As () const
 

Protected Member Functions

nonvirtual const char * _PeekAtNarrowSDKString () const
 

Detailed Description

This is a base class for Execution::Exception<> template, which gets mixed with the std c++ exception class, to mix in Stroika string support.

This probably should NOT be used directly.

Definition at line 64 of file Exceptions.h.

Constructor & Destructor Documentation

◆ ExceptionStringHelper()

Stroika::Foundation::Execution::ExceptionStringHelper::ExceptionStringHelper ( )
delete

activities default to NULLOPT - meaning "not specified" - which is different from "specified, and there were none".

Nothing is captured at construction.

See also
Throw () fills them in at the point of throw, but only for an exception which has not specified them - so an exception built once and thrown many times (e.g. a static const) reports the context of each throw rather than freezing the first one.

Pass them explicitly here, or

See also
ImbueActivities (), if you are not going through Throw ().

Member Function Documentation

◆ GetBasicErrorMessage()

Characters::String Stroika::Foundation::Execution::ExceptionStringHelper::GetBasicErrorMessage ( ) const

Return error message without added 'activities'.

Definition at line 37 of file Exceptions.inl.

◆ GetFullErrorMessage()

Characters::String Stroika::Foundation::Execution::ExceptionStringHelper::GetFullErrorMessage ( ) const

Return error message with added 'activities'

Definition at line 41 of file Exceptions.inl.

◆ GetActivities()

optional< Containers::Stack< Activity<> > > Stroika::Foundation::Execution::ExceptionStringHelper::GetActivities ( ) const

Return the activity stack from when the exception was thrown. NOTE - see @Activity<>. This has little todo with the thread runtime stack. It refers to a logical stack of declared Activity<> objects.

Definition at line 46 of file Exceptions.inl.

◆ ImbueActivities()

void ExceptionStringHelper::ImbueActivities ( const optional< Containers::Stack< Activity<> > > &  activities)

Set, replace, or clear the activity stack. Any already-computed message text is discarded, since it depends on these.

Takes an optional for symmetry with the constructor and

See also
GetActivities (), so that every state is reachable. Passing nullopt returns the exception to "not specified", after which
Throw () will stamp in the context of the throw - which is what you want when forwarding an exception you did not construct.
Note
This invalidates any pointer previously returned by what (). That is allowed, and is why this is deliberately a NON-const member: the standard guarantees what ()'s result only "until the exception object is destroyed, or until a non-const member function on the exception object is called". Do not hold a what () pointer across a call to this.
See also
Throw () - which imbues a COPY it is about to throw, so nobody can be holding a what () pointer into it - is the normal caller, and is unaffected.
Note
Replacing is allowed on purpose: a caller doing this explicitly knows what it wants.
See also
Throw () is the one that will not overwrite - it imbues only when GetActivities () is nullopt, so deliberately-specified context always survives being thrown.

Definition at line 93 of file Exceptions.cpp.

◆ As()

template<typename T >
nonvirtual T Stroika::Foundation::Execution::ExceptionStringHelper::As ( ) const

Only implemented for o wstring o String

This returns the message callers should display to represent the error (e.g. in exception::c_str ()). For now, it returns GetFullErrorMessage () - but may someday change.

◆ _PeekAtNarrowSDKString()

const char * Stroika::Foundation::Execution::ExceptionStringHelper::_PeekAtNarrowSDKString ( ) const
protected

In order for subclasses to support the c++ exception::c_str () API, we need to convert the string/message to an SDKChar string, and have that lifetime be very long. So we store it in a std::string. And this function returns the pointer to that string. This object is immutable, so that the lifetime of the underlying return const char* is as long as this object.

Definition at line 62 of file Exceptions.inl.


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