forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterminate_handler.h
More file actions
31 lines (23 loc) · 809 Bytes
/
terminate_handler.h
File metadata and controls
31 lines (23 loc) · 809 Bytes
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
#pragma once
#include <exception>
#include "source/common/common/logger.h"
#include "source/common/common/non_copyable.h"
namespace Envoy {
class TerminateHandler : NonCopyable, protected Logger::Loggable<Logger::Id::main> {
public:
TerminateHandler() : previous_terminate_(logOnTerminate()) {}
~TerminateHandler() { std::set_terminate(previous_terminate_); }
private:
friend class TerminateHandlerTest;
/**
* Sets the std::terminate to a function which will log as much of a backtrace as
* possible, then call abort. Returns the previous handler.
*/
std::terminate_handler logOnTerminate() const;
/**
* Logs exception details when possible
*/
static void logException(const std::exception_ptr);
const std::terminate_handler previous_terminate_;
};
} // namespace Envoy