cbe13f1f359eab34a71411bc0ee5488f01224488
[oweals/minetest.git] / src / exceptions.h
1 #ifndef EXCEPTIONS_HEADER
2 #define EXCEPTIONS_HEADER
3
4 #include <exception>
5
6 class BaseException : public std::exception
7 {
8 public:
9         BaseException(const char *s)
10         {
11                 m_s = s;
12         }
13         virtual const char * what() const throw()
14         {
15                 return m_s;
16         }
17         const char *m_s;
18 };
19
20 class AsyncQueuedException : public BaseException
21 {
22 public:
23         AsyncQueuedException(const char *s):
24                 BaseException(s)
25         {}
26 };
27
28 class NotImplementedException : public BaseException
29 {
30 public:
31         NotImplementedException(const char *s):
32                 BaseException(s)
33         {}
34 };
35
36 class AlreadyExistsException : public BaseException
37 {
38 public:
39         AlreadyExistsException(const char *s):
40                 BaseException(s)
41         {}
42 };
43
44 class VersionMismatchException : public BaseException
45 {
46 public:
47         VersionMismatchException(const char *s):
48                 BaseException(s)
49         {}
50 };
51
52 class FileNotGoodException : public BaseException
53 {
54 public:
55         FileNotGoodException(const char *s):
56                 BaseException(s)
57         {}
58 };
59
60 class SerializationError : public BaseException
61 {
62 public:
63         SerializationError(const char *s):
64                 BaseException(s)
65         {}
66 };
67
68 class LoadError : public BaseException
69 {
70 public:
71         LoadError(const char *s):
72                 BaseException(s)
73         {}
74 };
75
76 class ContainerFullException : public BaseException
77 {
78 public:
79         ContainerFullException(const char *s):
80                 BaseException(s)
81         {}
82 };
83
84 /*
85         Some "old-style" interrupts:
86 */
87
88 class InvalidPositionException : public BaseException
89 {
90 public:
91         InvalidPositionException():
92                 BaseException("Somebody tried to get/set something in a nonexistent position.")
93         {}
94         InvalidPositionException(const char *s):
95                 BaseException(s)
96         {}
97 };
98
99 class TargetInexistentException : public std::exception
100 {
101         virtual const char * what() const throw()
102         {
103                 return "Somebody tried to refer to something that doesn't exist.";
104         }
105 };
106
107 class NullPointerException : public std::exception
108 {
109         virtual const char * what() const throw()
110         {
111                 return "NullPointerException";
112         }
113 };
114
115 #endif
116