Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 3cc48e1

Browse files
authored
Merge pull request #1214 from KFilipek/doc_exceptions
[doxygen] add description for "exceptions" group
2 parents fe78a16 + 8fc76b5 commit 3cc48e1

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

doc/groups_definitions.dox

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,30 @@
163163
/** @defgroup data_view Data View*/
164164
/** @defgroup synchronization Synchronization Primitives*/
165165
/** @defgroup primitives Primitives*/
166-
/** @defgroup exceptions Exceptions*/
166+
/** @defgroup exceptions Exceptions
167+
* Possible exceptions that could be thrown by the libpmemobj++.
168+
*
169+
* In runtime, some operations may fail, then all you need is to catch the exception.
170+
* Every pmem exception has **std::runtime_error** in its inheritance tree
171+
* and contains proper message with an error description.
172+
* All exceptions can be caught using just **std::runtime_error**.
173+
* Look at the list on this page to explore all exceptions with their descriptions.
174+
*
175+
* Transaction handles uncaught exceptions thrown inside its scope, then aborts
176+
* and rethrow the previous exception. That way you never loose the original
177+
* exception and at the same time, the transaction state is handled
178+
* properly by the library.
179+
*
180+
* Let's consider following example:
181+
* @snippet examples/mpsc_queue/mpsc_queue.cpp mpsc_main
182+
*
183+
* There are plenty of try-catch blocks placed to handle possible errors that can happen in some conditions.
184+
* E.g. @ref pmem::obj::pool<T>::open can lead to @ref pmem::pool_error.
185+
* Next exception, **std::exception**, is placed to handle possible errors during allocation,
186+
* coming from @ref pmem::obj::make_persistent. Worth being careful using every new function
187+
* because some of exceptions are not obvious, e.g., pmem::obj::pool<T>::close
188+
* at the end of the code which may throw **std::logic_error**.
189+
*
190+
* You should check every function you will use in context of possible
191+
* exceptions and then handle them to avoid crash.
192+
**/

examples/mpsc_queue/mpsc_queue.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ single_threaded(pmem::obj::pool<root> pop)
8080

8181
//! [mpsc_queue_single_threaded_example]
8282

83+
//! [mpsc_main]
8384
int
8485
main(int argc, char *argv[])
8586
{
@@ -120,3 +121,4 @@ main(int argc, char *argv[])
120121
}
121122
return 0;
122123
}
124+
//! [mpsc_main]

include/libpmemobj++/pexceptions.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ exception_with_errormsg(Args &&... args)
7878
* Custom pool error class.
7979
*
8080
* Thrown when there is a runtime problem with some action on the
81-
* pool.
81+
* pool, e.g., object wasn't in a pool, invalid pool handle, etc.
8282
* @ingroup exceptions
8383
*/
8484
class pool_error : public std::runtime_error {
@@ -90,6 +90,8 @@ class pool_error : public std::runtime_error {
9090
* Custom pool error class.
9191
*
9292
* Thrown when there is an invalid argument passed to create/open pool.
93+
* Specialization of pool_error, which is thrown
94+
* when creating/opening pool failed.
9395
* @ingroup exceptions
9496
*/
9597
class pool_invalid_argument : public pool_error {
@@ -100,7 +102,8 @@ class pool_invalid_argument : public pool_error {
100102
/**
101103
* Custom transaction error class.
102104
*
103-
* Thrown when there is a runtime problem with a transaction.
105+
* Thrown when there is a runtime problem with a transaction, e.g.,
106+
* when the transaction is in the wrong stage, or on transaction abort.
104107
* @ingroup exceptions
105108
*/
106109
class transaction_error : public std::runtime_error {

0 commit comments

Comments
 (0)