E-MailRelay
gexceptionhandler.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gexceptionhandler.h
19///
20
21#ifndef G_NET_EXCEPTION_HANDLER_H
22#define G_NET_EXCEPTION_HANDLER_H
23
24#include "gdef.h"
25#include "gexceptionsource.h"
26#include <exception>
27
28namespace GNet
29{
30 class ExceptionHandler ;
31 class EventHandler ;
32}
33
34//| \class GNet::ExceptionHandler
35/// An abstract interface for handling exceptions thrown out of
36/// event-loop callbacks (socket/future events and timer events).
37/// If the handler just rethrows then the event loop will terminate.
38///
39/// The ExceptionHandler destructor calls disarm() on the EventHandlerList
40/// and TimerList so that an onException() callback is not delivered
41/// if the target object has been destroyed.
42///
44{
45public:
46 virtual ~ExceptionHandler() ;
47 ///< Destructor. Matching entries in the EventHandlerList and
48 ///< TimerList are disarm()ed.
49
50 virtual void onException( ExceptionSource * source , std::exception & e , bool done ) = 0 ;
51 ///< Called by the event loop when an exception is thrown out
52 ///< of an event loop callback. The exception is still active
53 ///< so it can be rethrown with "throw".
54 ///<
55 ///< The source parameter can be used to point to the object
56 ///< that received the original event loop callback. This
57 ///< requires the appropriate exception source pointer is
58 ///< defined when the event source is first registered with
59 ///< the event loop, otherwise it defaults to a null pointer.
60 ///< (The ExceptionSinkUnbound class is used where necessary
61 ///< to encourage the definition of a valid exception source
62 ///< pointer.)
63 ///<
64 ///< The 'done' parameter indicates whether the exception
65 ///< was of type GNet::Done.
66
67public:
68 ExceptionHandler() = default ;
69 ExceptionHandler( const ExceptionHandler & ) = delete ;
70 ExceptionHandler( ExceptionHandler && ) = delete ;
71 void operator=( const ExceptionHandler & ) = delete ;
72 void operator=( ExceptionHandler && ) = delete ;
73} ;
74
75#endif
An abstract interface for handling exceptions thrown out of event-loop callbacks (socket/future event...
virtual ~ExceptionHandler()
Destructor.
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.
A mixin base class that identifies the source of an exception when delivered to GNet::ExceptionHandle...
Network classes.
Definition: gdef.h:1115