blob: a889d76d0a87227e4e08ee5fa8fd476b7d3e7a94 (
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
57
58
59
60
61
62
|
#include "defs.h"
#include "mkql_terminator.h"
#include <yql/essentials/core/issue/yql_issue.h>
#include <util/string/builder.h>
namespace NKikimr {
namespace NMiniKQL {
TTerminateException::TTerminateException()
: TErrorException(NYql::EYqlIssueCode::TIssuesIds_EIssueCode_CORE_RUNTIME_ERROR)
{}
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 TTerminateException() << fullMessage;
}
TOnlyThrowingBindTerminator::TOnlyThrowingBindTerminator()
: TBindTerminator(this)
{
}
void TOnlyThrowingBindTerminator::Terminate(const char* message) const {
ythrow TTerminateException() << message;
}
[[noreturn]] void MKQLTerminate(const char* message) {
if (const auto t = TBindTerminator::Terminator)
t->Terminate(message);
if (message)
Cerr << message << Endl;
::abort();
}
}
}
|