aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/utils/exceptions.h
blob: 8df5307da2d7b04fb8ba26d7a4194b26dad6021b (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
#pragma once

#include <util/generic/yexception.h>

namespace NYql {

// This exception can separate code line and file name from the error message 
struct TCodeLineException: public yexception {

    TSourceLocation SourceLocation;
    mutable TString Message;
    ui32 Code;

    TCodeLineException(ui32 code);

    TCodeLineException(const TSourceLocation& sl, const TCodeLineException& t);

    virtual const char* what() const noexcept override;

    const char* GetRawMessage() const;

};

TCodeLineException operator+(const TSourceLocation& sl, TCodeLineException&& t);

#define YQL_ENSURE_CODELINE(CONDITION, CODE, ...)     \
    do {                                   \
        if (Y_UNLIKELY(!(CONDITION))) {    \
            ythrow TCodeLineException(CODE) << __VA_ARGS__; \
        }                                  \
    } while (0)

} // namespace NYql