Skip to content

Commit 62131dc

Browse files
committed
better
1 parent 2e70c05 commit 62131dc

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/Common/Exception.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,19 +270,23 @@ void Exception::clearThreadFramePointers()
270270
thread_frame_pointers.frame_pointers.clear();
271271
}
272272

273+
bool Exception::isErrorCodeImportant() const
274+
{
275+
const int error_code = code();
276+
return error_code == ErrorCodes::LOGICAL_ERROR
277+
|| error_code == ErrorCodes::POTENTIALLY_BROKEN_DATA_PART
278+
|| error_code == ErrorCodes::REPLICA_ALREADY_EXISTS
279+
|| error_code == ErrorCodes::NOT_ENOUGH_SPACE
280+
|| error_code == ErrorCodes::CORRUPTED_DATA
281+
|| error_code == ErrorCodes::CHECKSUM_DOESNT_MATCH
282+
|| error_code == ErrorCodes::CANNOT_WRITE_TO_FILE_DESCRIPTOR;
283+
}
284+
273285
Exception::~Exception()
274286
{
275-
if (logged != nullptr && logged->load(std::memory_order_relaxed))
276-
{
277-
const int error_code = code();
278-
const bool is_error_important = error_code == ErrorCodes::LOGICAL_ERROR
279-
|| error_code == ErrorCodes::POTENTIALLY_BROKEN_DATA_PART
280-
|| error_code == ErrorCodes::REPLICA_ALREADY_EXISTS
281-
|| error_code == ErrorCodes::NOT_ENOUGH_SPACE
282-
|| error_code == ErrorCodes::CORRUPTED_DATA
283-
|| error_code == ErrorCodes::CHECKSUM_DOESNT_MATCH
284-
|| error_code == ErrorCodes::CANNOT_WRITE_TO_FILE_DESCRIPTOR;
285-
tryLogException(*this, getLogger("~Exception"), "An important exception was likely ignored, here it is");
287+
if (logged != nullptr && !logged->load(std::memory_order_relaxed) && isErrorCodeImportant())
288+
{
289+
LOG_ERROR(getLogger("~Exception"), "An important exception was likely ignored, here it is: {}", getExceptionMessage(*this, /*with_stacktrace=*/ true));
286290
}
287291
}
288292

src/Common/Exception.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ class Exception : public Poco::Exception
181181
}
182182
}
183183

184+
/// Indicates if the error code triggers alerts in ClickHouse Cloud
185+
bool isErrorCodeImportant() const;
186+
184187
private:
185188
#ifndef STD_EXCEPTION_HAS_STACK_TRACE
186189
StackTrace trace;

0 commit comments

Comments
 (0)