aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/exception/exception.cpp
blob: 2729511d5a6af643205d47c281abbd6661bf5093 (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
#include "exception.h"

namespace NYT {

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

TSimpleException::TSimpleException(TString message)
    : Message_(std::move(message))
{ }

const TString& TSimpleException::GetMessage() const
{
    return Message_;
}

const char* TSimpleException::what() const noexcept
{
    return Message_.c_str();
}

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

TCompositeException::TCompositeException(TString message)
    : TSimpleException(std::move(message))
    , What_(Message_)
{ }

TCompositeException::TCompositeException(
    const std::exception& exception,
    TString message)
    : TSimpleException(message)
    , InnerException_(std::current_exception())
    , What_(message + "\n" + exception.what())
{ }

const std::exception_ptr& TCompositeException::GetInnerException() const
{
    return InnerException_;
}

const char* TCompositeException::what() const noexcept
{
    return What_.c_str();
}

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

} // namespace NYT