E-MailRelay
|
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer. More...
#include <gexceptionsink.h>
Public Types | |
enum class | Type { Null , Rethrow , Log } |
Public Member Functions | |
ExceptionSink (Type=Type::Rethrow, ExceptionSource *source=nullptr) noexcept | |
Constructor. More... | |
ExceptionSink (ExceptionHandler &eh, ExceptionSource *source) noexcept | |
Constructor. More... | |
ExceptionSink (ExceptionHandler *eh, ExceptionSource *source) noexcept | |
Constructor. More... | |
ExceptionSink (std::nullptr_t, ExceptionSource *)=delete | |
Deleted override to prohibit a null ExceptionHandler. | |
ExceptionHandler * | eh () const noexcept |
Returns the exception handler pointer. More... | |
ExceptionSource * | esrc () const noexcept |
Returns the exception source pointer. More... | |
void | call (std::exception &e, bool done) |
Calls the exception handler's onException() method. More... | |
void | reset () noexcept |
Resets the pointers. More... | |
bool | set () const noexcept |
Returns true if eh() is not null. More... | |
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
The EventHandlerList and TimerList classes associate an event handler and ExceptionSink with each event source (file descriptor or timer). If the event handler throws an exception then the associated ExceptionHandler's onException() method is called, via ExceptionSink::call().
An onException() implementation normally just rethrows the exception to terminate the event loop, but sometimes the exception can be handled less drastically, perhaps by deleting the object identified as the exception source.
For example, Server objects create and contain ServerPeer objects:
The ExceptionSinkUnbound class is used as syntactic sugar to force factory methods to supply an ExceptionSource pointer that points to the most-derived ServerPeer class.
So then the ServerPeer constructor has a bound ExceptionSink that it can pass to its timers etc. and to the event-handler list:
Definition at line 99 of file gexceptionsink.h.
|
strong |
Definition at line 102 of file gexceptionsink.h.
|
explicitnoexcept |
Constructor.
Definition at line 41 of file gexceptionsink.cpp.
|
noexcept |
Constructor.
The ExceptionHandler reference must remain valid as the ExceptionSink is copied around.
Definition at line 46 of file gexceptionsink.cpp.
|
noexcept |
Constructor.
The ExceptionHandler pointer must remain valid as the ExceptionSink is copied around.
Definition at line 52 of file gexceptionsink.cpp.
void GNet::ExceptionSink::call | ( | std::exception & | e, |
bool | done | ||
) |
Calls the exception handler's onException() method.
Used by EventHandlerList and TimerList. Exceptions thrown out of the onException() implementation are allowed to propagate.
Definition at line 68 of file gexceptionsink.cpp.
|
noexcept |
Returns the exception handler pointer.
Definition at line 58 of file gexceptionsink.cpp.
|
noexcept |
Returns the exception source pointer.
Definition at line 63 of file gexceptionsink.cpp.
|
noexcept |
Resets the pointers.
Definition at line 76 of file gexceptionsink.cpp.
|
noexcept |
Returns true if eh() is not null.
Definition at line 82 of file gexceptionsink.cpp.