aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/mkql_terminator.h
blob: 3bfaa3f20b99ef7fe74af5a541dc0f294dc6670b (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
#pragma once

#include <util/generic/noncopyable.h>
#include <util/system/compiler.h>

#include <yql/essentials/public/issue/yql_issue.h>

namespace NKikimr {

namespace NMiniKQL {

class TTerminateException : public NYql::TErrorException
{
public:
    TTerminateException();
};

///////////////////////////////////////////////////////////////////////////////
// ITerminator
///////////////////////////////////////////////////////////////////////////////
class ITerminator
{
public:
    virtual ~ITerminator() = default;
    virtual void Terminate(const char* message) const = 0;
};

struct TBindTerminator : private TNonCopyable {
    TBindTerminator(ITerminator* terminator);
    ~TBindTerminator();

    static thread_local ITerminator* Terminator;
private:
    ITerminator* PreviousTerminator;
};

struct TThrowingBindTerminator : public TBindTerminator, public ITerminator {
    TThrowingBindTerminator();
    void Terminate(const char* message) const final;
};

struct TOnlyThrowingBindTerminator : public TBindTerminator, public ITerminator {
    TOnlyThrowingBindTerminator();
    void Terminate(const char* message) const final;
};



[[noreturn]] void MKQLTerminate(const char* message);

}

}