summaryrefslogtreecommitdiffstats
path: root/yql/essentials/utils/exceptions.h
blob: 1fd13e39f61d7d59eb551708b1e7465166eb6dbe (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
#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