aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/exception/exception.h
blob: 7d35637d6058d88df1c7a79cd12a9df1d732aa3c (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
#pragma once

#include <util/generic/string.h>

#include <exception>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////
// These are poor man's versions of NYT::TErrorException to be used in
// a limited subset of core libraries that are needed to implement NYT::TError.

class TSimpleException
    : public std::exception
{
public:
    explicit TSimpleException(TString message);

    const TString& GetMesage() const;
    const char* what() const noexcept override;

protected:
    const TString Message_;
};

class TCompositeException
    : public TSimpleException
{
public:
    explicit TCompositeException(TString message);
    TCompositeException(
        const std::exception& exception,
        TString message);

    const std::exception_ptr& GetInnerException() const;
    const char* what() const noexcept override;

private:
    const std::exception_ptr InnerException_;
    const TString What_;
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT