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