]> git.lizzy.rs Git - dragonfireclient.git/blob - src/exceptions.h
Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenu
[dragonfireclient.git] / src / exceptions.h
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef EXCEPTIONS_HEADER
21 #define EXCEPTIONS_HEADER
22
23 #include <exception>
24
25 class BaseException : public std::exception
26 {
27 public:
28         BaseException(const char *s)
29         {
30                 m_s = s;
31         }
32         virtual const char * what() const throw()
33         {
34                 return m_s;
35         }
36         const char *m_s;
37 };
38
39 class AsyncQueuedException : public BaseException
40 {
41 public:
42         AsyncQueuedException(const char *s):
43                 BaseException(s)
44         {}
45 };
46
47 class NotImplementedException : public BaseException
48 {
49 public:
50         NotImplementedException(const char *s):
51                 BaseException(s)
52         {}
53 };
54
55 class AlreadyExistsException : public BaseException
56 {
57 public:
58         AlreadyExistsException(const char *s):
59                 BaseException(s)
60         {}
61 };
62
63 class VersionMismatchException : public BaseException
64 {
65 public:
66         VersionMismatchException(const char *s):
67                 BaseException(s)
68         {}
69 };
70
71 class FileNotGoodException : public BaseException
72 {
73 public:
74         FileNotGoodException(const char *s):
75                 BaseException(s)
76         {}
77 };
78
79 class SerializationError : public BaseException
80 {
81 public:
82         SerializationError(const char *s):
83                 BaseException(s)
84         {}
85 };
86
87 class LoadError : public BaseException
88 {
89 public:
90         LoadError(const char *s):
91                 BaseException(s)
92         {}
93 };
94
95 class ContainerFullException : public BaseException
96 {
97 public:
98         ContainerFullException(const char *s):
99                 BaseException(s)
100         {}
101 };
102
103 class SettingNotFoundException : public BaseException
104 {
105 public:
106         SettingNotFoundException(const char *s):
107                 BaseException(s)
108         {}
109 };
110
111 class InvalidFilenameException : public BaseException
112 {
113 public:
114         InvalidFilenameException(const char *s):
115                 BaseException(s)
116         {}
117 };
118
119 class ProcessingLimitException : public BaseException
120 {
121 public:
122         ProcessingLimitException(const char *s):
123                 BaseException(s)
124         {}
125 };
126
127 class CommandLineError : public BaseException
128 {
129 public:
130         CommandLineError(const char *s):
131                 BaseException(s)
132         {}
133 };
134
135 class ItemNotFoundException : public BaseException
136 {
137 public:
138         ItemNotFoundException(const char *s):
139                 BaseException(s)
140         {}
141 };
142
143 // Only used on Windows (SEH)
144 class FatalSystemException : public BaseException
145 {
146 public:
147         FatalSystemException(const char *s):
148                 BaseException(s)
149         {}
150 };
151
152 /*
153         Some "old-style" interrupts:
154 */
155
156 class InvalidPositionException : public BaseException
157 {
158 public:
159         InvalidPositionException():
160                 BaseException("Somebody tried to get/set something in a nonexistent position.")
161         {}
162         InvalidPositionException(const char *s):
163                 BaseException(s)
164         {}
165 };
166
167 class TargetInexistentException : public std::exception
168 {
169         virtual const char * what() const throw()
170         {
171                 return "Somebody tried to refer to something that doesn't exist.";
172         }
173 };
174
175 class NullPointerException : public std::exception
176 {
177         virtual const char * what() const throw()
178         {
179                 return "NullPointerException";
180         }
181 };
182
183 #endif
184