summaryrefslogtreecommitdiff
path: root/src/exception.hh
blob: 28f410291cfd9e66c1b5db35509b413213b2d452 (plain)
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
#ifndef exception_hh_INCLUDED
#define exception_hh_INCLUDED

#include "string.hh"

namespace Kakoune
{

struct exception
{
    virtual ~exception() = default;
    virtual StringView what() const;
};

struct runtime_error : exception
{
    runtime_error(String what)
        : m_what(std::move(what)) {}

    StringView what() const override { return m_what; }
    void set_what(String what) { m_what = std::move(what); }

private:
    String m_what;
};

struct failure : runtime_error
{
    using runtime_error::runtime_error;
};

struct cancel : runtime_error
{
    cancel() : runtime_error("cancellation requested") {}
};

struct logic_error : exception
{
};

}

#endif // exception_hh_INCLUDED