PMDK C++ bindings
1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Possible exceptions that could be thrown by the libpmemobj++. More...
Classes | |
class | pmem::pool_error |
Custom pool error class. More... | |
class | pmem::pool_invalid_argument |
Custom pool error class. More... | |
class | pmem::transaction_error |
Custom transaction error class. More... | |
class | pmem::lock_error |
Custom lock error class. More... | |
class | pmem::transaction_alloc_error |
Custom transaction error class. More... | |
class | pmem::transaction_out_of_memory |
Custom out of memory error class. More... | |
class | pmem::transaction_free_error |
Custom transaction error class. More... | |
class | pmem::transaction_scope_error |
Custom transaction error class. More... | |
class | pmem::manual_tx_abort |
Custom transaction error class. More... | |
class | pmem::layout_error |
Custom layout error class. More... | |
class | pmem::ctl_error |
Custom ctl error class. More... | |
class | pmem::defrag_error |
Custom defrag error class. More... | |
Possible exceptions that could be thrown by the libpmemobj++.
In runtime, some operations may fail, then all you need is to catch the exception. Every pmem exception has std::runtime_error
in its inheritance tree, which means that all exceptions can be caught using just this type. Each exception contains proper message with an error description.
Look at the list on this page to explore all exceptions with their descriptions.
Transaction handles uncaught exceptions thrown inside its scope, then aborts and rethrow the previous exception. That way you never loose the original exception and at the same time, the transaction state is handled properly by the library.
Let's consider following example:
There are plenty of try-catch blocks placed to handle possible errors that can occur in some conditions. E.g. pmem::obj::pool<T>::open can lead to pmem::pool_error. The next exception, std::exception, is placed to handle possible errors during allocation, coming from pmem::obj::make_persistent. Worth being careful using any new function because some exceptions are not obvious, e.g., pmem::obj::pool<T>::close at the end of the code, which may throw std::logic_error.
You should check every function you will use in the context of possible exceptions and then handle them to avoid a crash.