forked from Abc-Arbitrage/Disruptor-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIgnoreExceptionHandler.h
More file actions
76 lines (63 loc) · 2.56 KB
/
Copy pathIgnoreExceptionHandler.h
File metadata and controls
76 lines (63 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include <iostream>
#include <sstream>
#include "Disruptor/IExceptionHandler.h"
#include "Disruptor/TypeInfo.h"
namespace Disruptor
{
/**
* Convenience implementation of an exception handler that using Console.WriteLine to log the exception
*/
template <class T>
class IgnoreExceptionHandler : public IExceptionHandler< T >
{
public:
/**
* Strategy for handling uncaught exceptions when processing an event.
*
* \param ex exception that propagated from the IEventHandler<T>
* \param sequence sequence of the event which cause the exception.
* \param evt event being processed when the exception occurred.
*/
void handleEventException(const std::exception& ex, std::int64_t sequence, T& /*evt*/) override
{
std::stringstream stream;
stream << "Exception processing sequence " << sequence << " for event " << Utils::getMetaTypeInfo< T >().fullyQualifiedName() << ": " << ex.what();
std::cerr << stream.str() << std::endl;
}
/**
* Callback to notify of an exception during ILifecycleAware.onStart()
*
* \param ex ex throw during the starting process.
*/
void handleOnStartException(const std::exception& ex) override
{
std::stringstream stream;
stream << "Exception during OnStart(): " << ex.what();
std::cerr << stream.str() << std::endl;
}
/**
* Callback to notify of an exception during ILifecycleAware.onShutdown()
*
* \param ex ex throw during the shutdown process.
*/
void handleOnShutdownException(const std::exception& ex) override
{
std::stringstream stream;
stream << "Exception during OnShutdown(): " << ex.what();
std::cerr << stream.str() << std::endl;
}
/**
* Callback to notify of an exception during ITimeoutHandler.onTimeout()
*
* \param ex ex throw during the starting process.
* \param sequence sequence of the event which cause the exception.
*/
void handleOnTimeoutException(const std::exception& ex, std::int64_t sequence) override
{
std::stringstream stream;
stream << "Exception during OnTimeout() processing sequence " << sequence << " for event " << Utils::getMetaTypeInfo< T >().fullyQualifiedName() << ": " << ex.what();
std::cerr << stream.str() << std::endl;
}
};
} // namespace Disruptor