31 namespace ExceptionSinkImp
33 struct LogExceptionHandler : ExceptionHandler
35 void onException( ExceptionSource * , std::exception & e ,
bool net_done )
override
38 G_LOG(
"GNet::ExceptionSink: exception: " << e.what() ) ;
61 static ExceptionSinkImp::LogExceptionHandler log_only_exception_handler ;
62 return { log_only_exception_handler ,
nullptr } ;
84 G_ASSERT( m_eh !=
nullptr ) ;
85 m_eh->onException( m_esrc , e , done ) ;
96 return m_eh != nullptr ;
111 G_ASSERT( eh !=
nullptr ) ;
116 return { m_eh , source } ;
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket/future event...
virtual void onException(ExceptionSource *source, std::exception &e, bool done)=0
Called by the event loop when an exception is thrown out of an event loop callback.
ExceptionSinkUnbound(ExceptionHandler *eh)
Constructor.
ExceptionSink bind(ExceptionSource *source) const
Returns a sink object with the source pointer set.
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
ExceptionHandler * eh() const noexcept
Returns the exception handler pointer.
ExceptionSource * esrc() const noexcept
Returns the exception source pointer.
void call(std::exception &e, bool done)
Calls the exception handler's onException() method.
void reset() noexcept
Resets the object as if default constructed.
bool set() const noexcept
Returns true if eh() is not null.
static ExceptionSink logOnly()
A factory function for an exception handler that logs the exception as an error but does not re-throw...
ExceptionSink() noexcept
Default constructor for an exception handler that rethrows.
static ExceptionSink rethrow()
A factory function for an exception handler that rethrows.
A mixin base class that identifies the source of an exception when delivered to GNet::ExceptionHandle...