Minetest  5.4.0
exceptions.h
Go to the documentation of this file.
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 #pragma once
21 
22 #include <exception>
23 #include <string>
24 
25 
26 class BaseException : public std::exception
27 {
28 public:
29  BaseException(const std::string &s) throw(): m_s(s) {}
30  ~BaseException() throw() = default;
31 
32  virtual const char * what() const throw()
33  {
34  return m_s.c_str();
35  }
36 protected:
37  std::string m_s;
38 };
39 
41 public:
42  AlreadyExistsException(const std::string &s): BaseException(s) {}
43 };
44 
46 public:
47  VersionMismatchException(const std::string &s): BaseException(s) {}
48 };
49 
51 public:
52  FileNotGoodException(const std::string &s): BaseException(s) {}
53 };
54 
56 public:
57  DatabaseException(const std::string &s): BaseException(s) {}
58 };
59 
61 public:
62  SerializationError(const std::string &s): BaseException(s) {}
63 };
64 
65 class PacketError : public BaseException {
66 public:
67  PacketError(const std::string &s): BaseException(s) {}
68 };
69 
71 public:
72  SettingNotFoundException(const std::string &s): BaseException(s) {}
73 };
74 
76 public:
77  ItemNotFoundException(const std::string &s): BaseException(s) {}
78 };
79 
80 class ServerError : public BaseException {
81 public:
82  ServerError(const std::string &s): BaseException(s) {}
83 };
84 
86 public:
87  ClientStateError(const std::string &s): BaseException(s) {}
88 };
89 
90 class PrngException : public BaseException {
91 public:
92  PrngException(const std::string &s): BaseException(s) {}
93 };
94 
95 class ModError : public BaseException {
96 public:
97  ModError(const std::string &s): BaseException(s) {}
98 };
99 
100 
101 /*
102  Some "old-style" interrupts:
103 */
104 
106 public:
108  BaseException("One or more noise parameters were invalid or require "
109  "too much memory")
110  {}
111 
112  InvalidNoiseParamsException(const std::string &s):
113  BaseException(s)
114  {}
115 };
116 
118 {
119 public:
121  BaseException("Somebody tried to get/set something in a nonexistent position.")
122  {}
123  InvalidPositionException(const std::string &s):
124  BaseException(s)
125  {}
126 };
Definition: exceptions.h:40
AlreadyExistsException(const std::string &s)
Definition: exceptions.h:42
Definition: exceptions.h:27
BaseException(const std::string &s)
Definition: exceptions.h:29
virtual const char * what() const
Definition: exceptions.h:32
std::string m_s
Definition: exceptions.h:37
~BaseException()=default
Definition: exceptions.h:85
ClientStateError(const std::string &s)
Definition: exceptions.h:87
Definition: exceptions.h:55
DatabaseException(const std::string &s)
Definition: exceptions.h:57
Definition: exceptions.h:50
FileNotGoodException(const std::string &s)
Definition: exceptions.h:52
Definition: exceptions.h:105
InvalidNoiseParamsException(const std::string &s)
Definition: exceptions.h:112
InvalidNoiseParamsException()
Definition: exceptions.h:107
Definition: exceptions.h:118
InvalidPositionException()
Definition: exceptions.h:120
InvalidPositionException(const std::string &s)
Definition: exceptions.h:123
Definition: exceptions.h:75
ItemNotFoundException(const std::string &s)
Definition: exceptions.h:77
Definition: exceptions.h:95
ModError(const std::string &s)
Definition: exceptions.h:97
Definition: exceptions.h:65
PacketError(const std::string &s)
Definition: exceptions.h:67
Definition: exceptions.h:90
PrngException(const std::string &s)
Definition: exceptions.h:92
Definition: exceptions.h:60
SerializationError(const std::string &s)
Definition: exceptions.h:62
Definition: exceptions.h:80
ServerError(const std::string &s)
Definition: exceptions.h:82
Definition: exceptions.h:70
SettingNotFoundException(const std::string &s)
Definition: exceptions.h:72
Definition: exceptions.h:45
VersionMismatchException(const std::string &s)
Definition: exceptions.h:47