blob: b2f9e0ca7fda637f42b9fd621b8d0e642ce4e9ff (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#include "defs.h"
#include "mkql_terminator.h"
#include <util/string/builder.h>
namespace NKikimr {
namespace NMiniKQL {
thread_local ITerminator* TBindTerminator::Terminator = nullptr;
TBindTerminator::TBindTerminator(ITerminator* terminator)
: PreviousTerminator(Terminator)
{
Terminator = terminator;
}
TBindTerminator::~TBindTerminator()
{
Terminator = PreviousTerminator;
}
TThrowingBindTerminator::TThrowingBindTerminator()
: TBindTerminator(this)
{
}
void TThrowingBindTerminator::Terminate(const char* message) const {
TStringBuf reason = (message ? TStringBuf(message) : TStringBuf("(unknown)"));
TString fullMessage = TStringBuilder() <<
"Terminate was called, reason(" << reason.size() << "): " << reason << Endl;
ythrow yexception() << fullMessage;
}
TOnlyThrowingBindTerminator::TOnlyThrowingBindTerminator()
: TBindTerminator(this)
{
}
void TOnlyThrowingBindTerminator::Terminate(const char* message) const {
ythrow yexception() << message;
}
[[noreturn]] void MKQLTerminate(const char* message) {
if (const auto t = TBindTerminator::Terminator)
t->Terminate(message);
if (message)
Cerr << message << Endl;
::abort();
}
}
}
|