Luanti 5.16.0-dev
 
Loading...
Searching...
No Matches
exceptions.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include <exception>
8#include <string>
9
10
11class BaseException : public std::exception
12{
13public:
14 BaseException(const std::string &s) noexcept: m_s(s) {}
15 ~BaseException() throw() = default;
16
17 virtual const char * what() const noexcept
18 {
19 return m_s.c_str();
20 }
21
22 BaseException &append(const std::string &what)
23 {
24 m_s.append(what);
25 return *this;
26 }
27protected:
28 std::string m_s;
29};
30
32public:
33 AlreadyExistsException(const std::string &s): BaseException(s) {}
34};
35
37public:
38 VersionMismatchException(const std::string &s): BaseException(s) {}
39};
40
42public:
43 FileNotGoodException(const std::string &s): BaseException(s) {}
44};
45
47public:
48 DatabaseException(const std::string &s): BaseException(s) {}
49};
50
52public:
53 SerializationError(const std::string &s): BaseException(s) {}
54};
55
56class PacketError : public BaseException {
57public:
58 PacketError(const std::string &s): BaseException(s) {}
59};
60
62public:
63 SettingNotFoundException(const std::string &s): BaseException(s) {}
64};
65
67public:
68 ItemNotFoundException(const std::string &s): BaseException(s) {}
69};
70
71class ServerError : public BaseException {
72public:
73 ServerError(const std::string &s): BaseException(s) {}
74};
75
77public:
78 ClientStateError(const std::string &s): BaseException(s) {}
79};
80
82public:
83 PrngException(const std::string &s): BaseException(s) {}
84};
85
87public:
88 ShaderException(const std::string &s): BaseException(s) {}
89};
90
91class ModError : public BaseException {
92public:
93 ModError(const std::string &s): BaseException(s) {}
94};
95
97public:
98 MisbehavedSSCSMException(const std::string &s): BaseException(s) {}
99};
100
101
102/*
103 Some "old-style" interrupts:
104*/
105
107public:
109 BaseException("One or more noise parameters were invalid or require "
110 "too much memory")
111 {}
112
113 InvalidNoiseParamsException(const std::string &s):
115 {}
116};
117
119{
120public:
122 BaseException("Somebody tried to get/set something in a nonexistent position.")
123 {}
124 InvalidPositionException(const std::string &s):
126 {}
127};
Definition exceptions.h:31
AlreadyExistsException(const std::string &s)
Definition exceptions.h:33
Definition exceptions.h:12
virtual const char * what() const noexcept
Definition exceptions.h:17
BaseException(const std::string &s) noexcept
Definition exceptions.h:14
BaseException & append(const std::string &what)
Definition exceptions.h:22
std::string m_s
Definition exceptions.h:28
~BaseException()=default
Definition exceptions.h:76
ClientStateError(const std::string &s)
Definition exceptions.h:78
Definition exceptions.h:46
DatabaseException(const std::string &s)
Definition exceptions.h:48
Definition exceptions.h:41
FileNotGoodException(const std::string &s)
Definition exceptions.h:43
Definition exceptions.h:106
InvalidNoiseParamsException(const std::string &s)
Definition exceptions.h:113
InvalidNoiseParamsException()
Definition exceptions.h:108
Definition exceptions.h:119
InvalidPositionException()
Definition exceptions.h:121
InvalidPositionException(const std::string &s)
Definition exceptions.h:124
Definition exceptions.h:66
ItemNotFoundException(const std::string &s)
Definition exceptions.h:68
Definition exceptions.h:96
MisbehavedSSCSMException(const std::string &s)
Definition exceptions.h:98
Definition exceptions.h:91
ModError(const std::string &s)
Definition exceptions.h:93
Definition exceptions.h:56
PacketError(const std::string &s)
Definition exceptions.h:58
Definition exceptions.h:81
PrngException(const std::string &s)
Definition exceptions.h:83
Definition exceptions.h:51
SerializationError(const std::string &s)
Definition exceptions.h:53
Definition exceptions.h:71
ServerError(const std::string &s)
Definition exceptions.h:73
Definition exceptions.h:61
SettingNotFoundException(const std::string &s)
Definition exceptions.h:63
Definition exceptions.h:86
ShaderException(const std::string &s)
Definition exceptions.h:88
Definition exceptions.h:36
VersionMismatchException(const std::string &s)
Definition exceptions.h:38