blob: 9d7dcece025d9d8d355768d34d6325bf8721c26d (
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
37
38
39
40
41
|
#pragma once
#include <util/system/yassert.h>
#include <exception>
/// @cond Doxygen_Suppress
namespace NYT::NDetail {
////////////////////////////////////////////////////////////////////////////////
template <typename T>
void FinishOrDie(T* pThis, const char* className) noexcept
{
auto fail = [&] (const char* what) {
Y_FAIL(
"\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("<unknown exception>");
}
}
}
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NDetail
/// @endcond
|