LMDBAL 0.6.0
LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer
Loading...
Searching...
No Matches
exceptions.h
1/*
2 * LMDB Abstraction Layer.
3 * Copyright (C) 2023 Yury Gubich <blue@macaw.me>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 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 General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#include <stdexcept>
22#include <string>
23#include <optional>
24
25namespace LMDBAL {
26
30class Exception : public std::exception {
31public:
32 Exception();
33 virtual ~Exception();
34
35 virtual std::string getMessage() const = 0;
37 const char* what() const noexcept( true ) override;
38};
39
43class Directory : public Exception {
44public:
50 Directory(const std::string& path);
51
52 std::string getMessage() const;
53private:
54 std::string path;
55};
56
60class Closed : public Exception {
61public:
69 Closed(const std::string& operation, const std::string& dbName, const std::optional<std::string>& tableName = std::nullopt);
70
71 std::string getMessage() const;
72private:
73 std::string operation;
74 std::string dbName;
75 std::optional<std::string> tableName;
76};
77
81class CursorNotReady : public Exception {
82public:
90 CursorNotReady(const std::string& operation, const std::string& dbName, const std::string& tableName);
91
92 std::string getMessage() const;
93private:
94 std::string operation;
95 std::string dbName;
96 std::string tableName;
97};
98
102class CursorEmpty : public Exception {
103public:
109 CursorEmpty(const std::string& operation);
110
111 std::string getMessage() const;
112private:
113 std::string operation;
114};
115
120public:
127 Opened(const std::string& dbName, const std::string& action);
128
129 std::string getMessage() const;
130private:
131 std::string dbName;
132 std::string action;
133};
134
138class NotFound : public Exception {
139public:
147 NotFound(const std::string& key, const std::string& dbName, const std::string& tableName);
148
149 std::string getMessage() const;
150private:
151 std::string key;
152 std::string dbName;
153 std::string tableName;
154};
155
160public:
167 StorageDuplicate(const std::string& dbName, const std::string& tableName);
168
169 std::string getMessage() const;
170private:
171 std::string dbName;
172 std::string tableName;
173};
174
178class Exist : public Exception {
179public:
187 Exist(const std::string& key, const std::string& dbName, const std::string& tableName);
188
189 std::string getMessage() const;
190private:
191 std::string key;
192 std::string dbName;
193 std::string tableName;
194};
195
200public:
208 TransactionTerminated(const std::string& dbName, const std::string& tableName, const std::string& action = "");
209
210 std::string getMessage() const;
211private:
212 std::string dbName;
213 std::string tableName;
214 std::string action;
215};
216
220class Unknown : public Exception {
221public:
229 Unknown(const std::string& dbName, const std::string& message, const std::optional<std::string>& tableName = std::nullopt);
230
231 std::string getMessage() const;
232private:
233 std::string dbName;
234 std::optional<std::string> tableName;
235 std::string msg;
236};
237
238}
Thrown if something in the database was called on closed state and it is not supported.
Definition exceptions.h:60
Thrown if an empty cursor was somehow operated.
Definition exceptions.h:102
Thrown if the cursor was operated in closed state.
Definition exceptions.h:81
Thrown if LMDBAL had issues creating or opening database directory.
Definition exceptions.h:43
Parent abstract class for all LMDBAL exceptions.
Definition exceptions.h:30
const char * what() const noexcept(true) override
system exception method that is actually called to show the message
Definition exceptions.cpp:27
virtual std::string getMessage() const =0
returns exception message
Thrown if there was a key conflict in one of the storages.
Definition exceptions.h:178
Thrown if something in the database was not found.
Definition exceptions.h:138
Thrown if something in the database was called on opened state and it is not supported.
Definition exceptions.h:119
Thrown if there was attempt to define storages with conflicting names.
Definition exceptions.h:159
Definition exceptions.h:199
Thrown if something unexpected happened.
Definition exceptions.h:220