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
49
50
51
52
53
54
55
56
57
#ifndef EXCEPTIONS_H_AQKXZ8P3
#define EXCEPTIONS_H_AQKXZ8P3

#include <QException>

namespace interpreter {

    class Exceptions : public QException
    {
        public:
            virtual QException *clone() const override
            {
                return new Exceptions(*this);
            }

            virtual void raise() const override
            {
                throw *this;
            }
    };

    class UnexpectedMessage : public Exceptions
    {
        protected:
            std::string m_details;
        public:
            UnexpectedMessage(QString details)
                : Exceptions()
                , m_details(details.toStdString())
            {
            }

            UnexpectedMessage(const UnexpectedMessage &other)
                : Exceptions(other)
                , m_details(other.m_details)
            {
            }

            virtual const char *what() const noexcept
            {
                return m_details.c_str();
            }

            virtual QException *clone() const override
            {
                return new UnexpectedMessage(*this);
            }

            virtual void raise() const override
            {
                throw *this;
            }
    };

}

#endif /* end of include guard: EXCEPTIONS_H_AQKXZ8P3 */