LMDBAL 0.6.2
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 <string_view>
24#include <optional>
25
26namespace LMDBAL {
27
31class Exception : public std::exception {
32public:
33 explicit Exception(std::size_t expectedSize = 0);
34 ~Exception() override;
35
36 std::string getMessage() const;
37 const char* what() const noexcept( true ) override;
38
39protected:
40 std::string_view appendSegment(std::string_view value);
41 void appendLiteral(std::string_view value);
42
43private:
44 std::string message;
45};
46
50class Directory : public Exception {
51public:
57 explicit Directory(std::string_view path);
58private:
59 std::string_view path;
60};
61
65class Closed : public Exception {
66public:
74 Closed(std::string_view operation, std::string_view dbName, std::optional<std::string_view> tableName = std::nullopt);
75private:
76 std::string_view operation;
77 std::string_view dbName;
78 std::optional<std::string_view> tableName;
79};
80
84class CursorNotReady : public Exception {
85public:
93 CursorNotReady(std::string_view operation, std::string_view dbName, std::string_view tableName);
94private:
95 std::string_view operation;
96 std::string_view dbName;
97 std::string_view tableName;
98};
99
103class CursorEmpty : public Exception {
104public:
110 explicit CursorEmpty(std::string_view operation);
111private:
112 std::string_view operation;
113};
114
118class Opened : public Exception {
119public:
126 Opened(std::string_view dbName, std::string_view action);
127private:
128 std::string_view dbName;
129 std::string_view action;
130};
131
135class NotFound : public Exception {
136public:
144 NotFound(std::string_view key, std::string_view dbName, std::string_view tableName);
145private:
146 std::string_view key;
147 std::string_view dbName;
148 std::string_view tableName;
149};
150
154class StorageDuplicate : public Exception {
155public:
162 StorageDuplicate(std::string_view dbName, std::string_view tableName);
163private:
164 std::string_view dbName;
165 std::string_view tableName;
166};
167
171class Exist : public Exception {
172public:
180 Exist(std::string_view key, std::string_view dbName, std::string_view tableName);
181private:
182 std::string_view key;
183 std::string_view dbName;
184 std::string_view tableName;
185};
186
190class TransactionTerminated : public Exception {
191public:
199 TransactionTerminated(std::string_view dbName, std::string_view tableName, std::string_view action = "");
200private:
201 std::string_view dbName;
202 std::string_view tableName;
203 std::string_view action;
204};
205
209class Unknown : public Exception {
210public:
218 Unknown(std::string_view dbName, std::string_view message, std::optional<std::string_view> tableName = std::nullopt);
219private:
220 std::string_view dbName;
221 std::optional<std::string_view> tableName;
222 std::string_view details;
223};
224
225}
Closed(std::string_view operation, std::string_view dbName, std::optional< std::string_view > tableName=std::nullopt)
Creates exception.
Definition exceptions.cpp:95
CursorEmpty(std::string_view operation)
Creates exception.
Definition exceptions.cpp:129
CursorNotReady(std::string_view operation, std::string_view dbName, std::string_view tableName)
Creates exception.
Definition exceptions.cpp:114
Directory(std::string_view path)
Creates exception.
Definition exceptions.cpp:90
std::string_view appendSegment(std::string_view value)
appends value to message and returns a view
Definition exceptions.cpp:80
std::string getMessage() const
returns exception message
Definition exceptions.cpp:72
void appendLiteral(std::string_view value)
appends value to message without returning a view
Definition exceptions.cpp:86
const char * what() const noexcept(true) override
system exception method that is actually called to show the message
Definition exceptions.cpp:76
Exist(std::string_view key, std::string_view dbName, std::string_view tableName)
Creates exception.
Definition exceptions.cpp:170
NotFound(std::string_view key, std::string_view dbName, std::string_view tableName)
Creates exception.
Definition exceptions.cpp:144
Opened(std::string_view dbName, std::string_view action)
Creates exception.
Definition exceptions.cpp:135
StorageDuplicate(std::string_view dbName, std::string_view tableName)
Creates exception.
Definition exceptions.cpp:158
TransactionTerminated(std::string_view dbName, std::string_view tableName, std::string_view action="")
Creates exception.
Definition exceptions.cpp:185
Unknown(std::string_view dbName, std::string_view message, std::optional< std::string_view > tableName=std::nullopt)
Creates exception.
Definition exceptions.cpp:208
Destroys a cache.
Definition base.h:36