mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 09:10:48 +00:00
dbms: better [#METR-9194].
This commit is contained in:
parent
4ef53f6acb
commit
025531e1c5
@ -51,6 +51,11 @@ void throwFromErrno(const std::string & s, int code = 0, int the_errno = errno);
|
||||
*/
|
||||
ExceptionPtr cloneCurrentException();
|
||||
|
||||
/** Попробовать записать исключение в лог (и забыть про него).
|
||||
* Можно использовать в деструкторах в блоке catch (...).
|
||||
*/
|
||||
void tryLogCurrentException(const char * log_name);
|
||||
|
||||
|
||||
void rethrowFirstException(Exceptions & exceptions);
|
||||
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
delete qlz_state;
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -162,6 +162,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <Yandex/logger_useful.h>
|
||||
|
||||
#include <DB/IO/WriteHelpers.h>
|
||||
|
||||
#include <DB/Core/Exception.h>
|
||||
@ -82,6 +84,49 @@ ExceptionPtr cloneCurrentException()
|
||||
}
|
||||
|
||||
|
||||
void tryLogCurrentException(const char * log_name)
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (const Exception & e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LOG_ERROR(&Logger::get(log_name), "Code: " << e.code() << ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what()
|
||||
<< ", Stack trace:\n\n" << e.getStackTrace().toString());
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
catch (const Poco::Exception & e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LOG_ERROR(&Logger::get(log_name), "Poco::Exception. Code: " << ErrorCodes::POCO_EXCEPTION << ", e.code() = " << e.code()
|
||||
<< ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what());
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LOG_ERROR(&Logger::get(log_name), "std::exception. Code: " << ErrorCodes::STD_EXCEPTION << ", e.what() = " << e.what());
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
try
|
||||
{
|
||||
LOG_ERROR(&Logger::get(log_name), "Unknown exception. Code: " << ErrorCodes::UNKNOWN_EXCEPTION);
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rethrowFirstException(Exceptions & exceptions)
|
||||
{
|
||||
for (size_t i = 0, size = exceptions.size(); i < size; ++i)
|
||||
|
Loading…
Reference in New Issue
Block a user