@@ -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+
273285Exception::~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
0 commit comments