Line data Source code
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 : #include <string>
25 :
26 :
27 0 : class BaseException : public std::exception
28 : {
29 : public:
30 6538 : BaseException(const std::string &s) throw()
31 6538 : {
32 6538 : m_s = s;
33 6538 : }
34 6538 : ~BaseException() throw() {}
35 0 : virtual const char * what() const throw()
36 : {
37 0 : return m_s.c_str();
38 : }
39 : protected:
40 : std::string m_s;
41 : };
42 :
43 : class AsyncQueuedException : public BaseException {
44 : public:
45 : AsyncQueuedException(const std::string &s): BaseException(s) {}
46 : };
47 :
48 : class NotImplementedException : public BaseException {
49 : public:
50 : NotImplementedException(const std::string &s): BaseException(s) {}
51 : };
52 :
53 0 : class AlreadyExistsException : public BaseException {
54 : public:
55 0 : AlreadyExistsException(const std::string &s): BaseException(s) {}
56 : };
57 :
58 0 : class VersionMismatchException : public BaseException {
59 : public:
60 0 : VersionMismatchException(const std::string &s): BaseException(s) {}
61 : };
62 :
63 0 : class FileNotGoodException : public BaseException {
64 : public:
65 0 : FileNotGoodException(const std::string &s): BaseException(s) {}
66 : };
67 :
68 0 : class SerializationError : public BaseException {
69 : public:
70 0 : SerializationError(const std::string &s): BaseException(s) {}
71 : };
72 :
73 0 : class PacketError : public BaseException {
74 : public:
75 0 : PacketError(const std::string &s): BaseException(s) {}
76 : };
77 :
78 : class LoadError : public BaseException {
79 : public:
80 : LoadError(const std::string &s): BaseException(s) {}
81 : };
82 :
83 : class ContainerFullException : public BaseException {
84 : public:
85 : ContainerFullException(const std::string &s): BaseException(s) {}
86 : };
87 :
88 33 : class SettingNotFoundException : public BaseException {
89 : public:
90 33 : SettingNotFoundException(const std::string &s): BaseException(s) {}
91 : };
92 :
93 0 : class InvalidFilenameException : public BaseException {
94 : public:
95 0 : InvalidFilenameException(const std::string &s): BaseException(s) {}
96 : };
97 :
98 : class ProcessingLimitException : public BaseException {
99 : public:
100 : ProcessingLimitException(const std::string &s): BaseException(s) {}
101 : };
102 :
103 : class CommandLineError : public BaseException {
104 : public:
105 : CommandLineError(const std::string &s): BaseException(s) {}
106 : };
107 :
108 1190 : class ItemNotFoundException : public BaseException {
109 : public:
110 1190 : ItemNotFoundException(const std::string &s): BaseException(s) {}
111 : };
112 :
113 0 : class ServerError : public BaseException {
114 : public:
115 0 : ServerError(const std::string &s): BaseException(s) {}
116 : };
117 :
118 0 : class ClientStateError : public BaseException {
119 : public:
120 0 : ClientStateError(std::string s): BaseException(s) {}
121 : };
122 :
123 0 : class PrngException : public BaseException {
124 : public:
125 0 : PrngException(std::string s): BaseException(s) {}
126 : };
127 :
128 : /*
129 : Some "old-style" interrupts:
130 : */
131 :
132 0 : class InvalidNoiseParamsException : public BaseException {
133 : public:
134 0 : InvalidNoiseParamsException():
135 : BaseException("One or more noise parameters were invalid or require "
136 0 : "too much memory")
137 0 : {}
138 :
139 : InvalidNoiseParamsException(const std::string &s):
140 : BaseException(s)
141 : {}
142 : };
143 :
144 244 : class InvalidPositionException : public BaseException
145 : {
146 : public:
147 244 : InvalidPositionException():
148 244 : BaseException("Somebody tried to get/set something in a nonexistent position.")
149 244 : {}
150 0 : InvalidPositionException(const std::string &s):
151 0 : BaseException(s)
152 0 : {}
153 : };
154 :
155 : class TargetInexistentException : public std::exception
156 : {
157 : virtual const char * what() const throw()
158 : {
159 : return "Somebody tried to refer to something that doesn't exist.";
160 : }
161 : };
162 :
163 : class NullPointerException : public std::exception
164 : {
165 : virtual const char * what() const throw()
166 : {
167 : return "NullPointerException";
168 : }
169 : };
170 :
171 : #endif
172 :
|