blob: 301377bff83725bd8a9d8389659aa08eea176a8b (
plain) (
blame)
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
|
#pragma once
#include <Poco/ErrorHandler.h>
#include <Common/Exception.h>
/** ErrorHandler for Poco::Thread,
* that in case of unhandled exception,
* logs exception message and terminates the process.
*/
class KillingErrorHandler : public Poco::ErrorHandler
{
public:
void exception(const Poco::Exception &) override { std::terminate(); }
void exception(const std::exception &) override { std::terminate(); }
void exception() override { std::terminate(); }
};
/** Log exception message.
*/
class ServerErrorHandler : public Poco::ErrorHandler
{
public:
void exception(const Poco::Exception &) override { logException(); }
void exception(const std::exception &) override { logException(); }
void exception() override { logException(); }
private:
Poco::Logger * log = &Poco::Logger::get("ServerErrorHandler");
void logException()
{
DB::tryLogCurrentException(log);
}
};
|