sitä sun tätä tekeillä, toimii kivasti
[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 class SettingNotFoundException : public BaseException
85 {
86 public:
87         SettingNotFoundException(const char *s):
88                 BaseException(s)
89         {}
90 };
91
92 class InvalidFilenameException : public BaseException
93 {
94 public:
95         InvalidFilenameException(const char *s):
96                 BaseException(s)
97         {}
98 };
99
100 /*
101         Some "old-style" interrupts:
102 */
103
104 class InvalidPositionException : public BaseException
105 {
106 public:
107         InvalidPositionException():
108                 BaseException("Somebody tried to get/set something in a nonexistent position.")
109         {}
110         InvalidPositionException(const char *s):
111                 BaseException(s)
112         {}
113 };
114
115 class TargetInexistentException : public std::exception
116 {
117         virtual const char * what() const throw()
118         {
119                 return "Somebody tried to refer to something that doesn't exist.";
120         }
121 };
122
123 class NullPointerException : public std::exception
124 {
125         virtual const char * what() const throw()
126         {
127                 return "NullPointerException";
128         }
129 };
130
131 #endif
132