#pragma once #include #include /// @cond Doxygen_Suppress namespace NYT::NDetail { //////////////////////////////////////////////////////////////////////////////// template void FinishOrDie(T* pThis, const char* className) noexcept { auto fail = [&] (const char* what) { Y_ABORT( "\n\n" "Destructor of %s caught exception during Finish: %s.\n" "Some data is probably has not been written.\n" "In order to handle such exceptions consider explicitly call Finish() method.\n", className, what); }; try { pThis->Finish(); } catch (const std::exception& ex) { if (!std::uncaught_exceptions()) { fail(ex.what()); } } catch (...) { if (!std::uncaught_exceptions()) { fail(""); } } } //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NDetail /// @endcond