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;
36
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
119class Opened : Exception {
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
159class StorageDuplicate : public Exception {
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
199class TransactionTerminated : public Exception {
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}
Closed(const std::string &operation, const std::string &dbName, const std::optional< std::string > &tableName=std::nullopt)
Creates exception.
Definition exceptions.cpp:39
std::string getMessage() const
returns exception message
Definition exceptions.cpp:49
CursorEmpty(const std::string &operation)
Creates exception.
Definition exceptions.cpp:75
std::string getMessage() const
returns exception message
Definition exceptions.cpp:79
std::string getMessage() const
returns exception message
Definition exceptions.cpp:68
CursorNotReady(const std::string &operation, const std::string &dbName, const std::string &tableName)
Creates exception.
Definition exceptions.cpp:58
Directory(const std::string &path)
Creates exception.
Definition exceptions.cpp:32
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
std::string getMessage() const
returns exception message
Definition exceptions.cpp:133
Exist(const std::string &key, const std::string &dbName, const std::string &tableName)
Creates exception.
Definition exceptions.cpp:123
std::string getMessage() const
returns exception message
Definition exceptions.cpp:105
NotFound(const std::string &key, const std::string &dbName, const std::string &tableName)
Creates exception.
Definition exceptions.cpp:95
Opened(const std::string &dbName, const std::string &action)
Creates exception.
Definition exceptions.cpp:83
std::string getMessage() const
returns exception message
Definition exceptions.cpp:89
std::string getMessage() const
returns exception message
Definition exceptions.cpp:117
StorageDuplicate(const std::string &dbName, const std::string &tableName)
Creates exception.
Definition exceptions.cpp:110
std::string getMessage() const
returns exception message
Definition exceptions.cpp:150
TransactionTerminated(const std::string &dbName, const std::string &tableName, const std::string &action="")
Creates exception.
Definition exceptions.cpp:140
Unknown(const std::string &dbName, const std::string &message, const std::optional< std::string > &tableName=std::nullopt)
Creates exception.
Definition exceptions.cpp:163
std::string getMessage() const
returns exception message
Definition exceptions.cpp:173