PMDK C++ bindings 1.13.0
This is the C++ bindings documentation for PMDK's libpmemobj.
pexceptions.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2/* Copyright 2016-2021, Intel Corporation */
3
9#ifndef LIBPMEMOBJ_CPP_PEXCEPTIONS_HPP
10#define LIBPMEMOBJ_CPP_PEXCEPTIONS_HPP
11
12#include <stdexcept>
13#include <string>
14#include <system_error>
15
16#include <libpmemobj/atomic_base.h>
17#include <libpmemobj/base.h>
18
19namespace pmem
20{
21
22namespace detail
23{
24
28inline std::string
30{
31#ifdef _WIN32
32 return std::string(pmemobj_errormsgU());
33#else
34 return std::string(pmemobj_errormsg());
35#endif
36}
37} /* namespace detail */
38
45class pool_error : public std::runtime_error {
46public:
47 using std::runtime_error::runtime_error;
48
50 with_pmemobj_errormsg()
51 {
52 (*this) = pool_error(what() + std::string(": ") +
54 return *this;
55 }
56};
57
64public:
65 using pool_error::pool_error;
66
68 with_pmemobj_errormsg()
69 {
70 (*this) = pool_invalid_argument(what() + std::string(": ") +
72 return *this;
73 }
74};
75
81class transaction_error : public std::runtime_error {
82public:
83 using std::runtime_error::runtime_error;
84
86 with_pmemobj_errormsg()
87 {
88 (*this) = transaction_error(what() + std::string(": ") +
90 return *this;
91 }
92};
93
100class lock_error : public std::system_error {
101public:
102 using std::system_error::system_error;
103
104 lock_error &
105 with_pmemobj_errormsg()
106 {
107 (*this) = lock_error(code(),
108 what() + std::string(": ") +
110 return *this;
111 }
112};
113
120public:
121 using transaction_error::transaction_error;
122
124 with_pmemobj_errormsg()
125 {
126 (*this) = transaction_alloc_error(what() + std::string(": ") +
128 return *this;
129 }
130};
131
138 public std::bad_alloc {
139public:
140 using transaction_alloc_error::transaction_alloc_error;
141 using transaction_alloc_error::what;
142
144 with_pmemobj_errormsg()
145 {
147 transaction_alloc_error::what() + std::string(": ") +
149 return *this;
150 }
151};
152
159public:
160 using transaction_alloc_error::transaction_alloc_error;
161
163 with_pmemobj_errormsg()
164 {
165 (*this) = transaction_free_error(what() + std::string(": ") +
167 return *this;
168 }
169};
170
176class transaction_scope_error : public std::logic_error {
177public:
178 using std::logic_error::logic_error;
179};
180
186class manual_tx_abort : public std::runtime_error {
187public:
188 using std::runtime_error::runtime_error;
189};
190
196class layout_error : public std::runtime_error {
197public:
198 using std::runtime_error::runtime_error;
199};
200
206class ctl_error : public std::runtime_error {
207public:
208 using std::runtime_error::runtime_error;
209
210 ctl_error &
211 with_pmemobj_errormsg()
212 {
213 (*this) = ctl_error(what() + std::string(": ") +
215 return *this;
216 }
217};
218
225class defrag_error : public std::runtime_error {
226public:
227 using std::runtime_error::runtime_error;
228
229 defrag_error(pobj_defrag_result result, const std::string &msg)
230 : std::runtime_error(msg), result(result)
231 {
232 }
233
235 with_pmemobj_errormsg()
236 {
237 (*this) = defrag_error(result,
238 what() + std::string(": ") +
240 return *this;
241 }
242
249 pobj_defrag_result result;
250};
251
252} /* namespace pmem */
253
254#endif /* LIBPMEMOBJ_CPP_PEXCEPTIONS_HPP */
Custom ctl error class.
Definition: pexceptions.hpp:206
Custom defrag error class.
Definition: pexceptions.hpp:225
pobj_defrag_result result
Results of the defragmentation run.
Definition: pexceptions.hpp:249
Custom layout error class.
Definition: pexceptions.hpp:196
Custom lock error class.
Definition: pexceptions.hpp:100
Custom transaction error class.
Definition: pexceptions.hpp:186
Custom pool error class.
Definition: pexceptions.hpp:45
Custom pool error class.
Definition: pexceptions.hpp:63
Custom transaction error class.
Definition: pexceptions.hpp:119
Custom transaction error class.
Definition: pexceptions.hpp:81
Custom transaction error class.
Definition: pexceptions.hpp:158
Custom out of memory error class.
Definition: pexceptions.hpp:138
Custom transaction error class.
Definition: pexceptions.hpp:176
std::string errormsg(void)
Return last libpmemobj error message as a std::string.
Definition: pexceptions.hpp:29
Persistent memory namespace.
Definition: allocation_flag.hpp:15