@@ -68,14 +68,13 @@ make_persistent(std::size_t N, allocation_flag flag = allocation_flag::none())
6868 sizeof (I) * N, detail::type_num<I>(), flag.value );
6969
7070 if (ptr == nullptr ) {
71+ const char *msg = " Failed to allocate persistent memory array" ;
7172 if (errno == ENOMEM)
72- throw pmem::transaction_out_of_memory (
73- " Failed to allocate persistent memory array" )
74- .with_pmemobj_errormsg ();
73+ throw detail::exception_with_errormsg<
74+ pmem::transaction_out_of_memory>(msg);
7575 else
76- throw pmem::transaction_alloc_error (
77- " Failed to allocate persistent memory array" )
78- .with_pmemobj_errormsg ();
76+ throw detail::exception_with_errormsg<
77+ pmem::transaction_alloc_error>(msg);
7978 }
8079
8180 /*
@@ -129,14 +128,13 @@ make_persistent(allocation_flag flag = allocation_flag::none())
129128 sizeof (I) * N, detail::type_num<I>(), flag.value );
130129
131130 if (ptr == nullptr ) {
131+ const char *msg = " Failed to allocate persistent memory array" ;
132132 if (errno == ENOMEM)
133- throw pmem::transaction_out_of_memory (
134- " Failed to allocate persistent memory array" )
135- .with_pmemobj_errormsg ();
133+ throw detail::exception_with_errormsg<
134+ pmem::transaction_out_of_memory>(msg);
136135 else
137- throw pmem::transaction_alloc_error (
138- " Failed to allocate persistent memory array" )
139- .with_pmemobj_errormsg ();
136+ throw detail::exception_with_errormsg<
137+ pmem::transaction_alloc_error>(msg);
140138 }
141139
142140 /*
@@ -201,9 +199,9 @@ delete_persistent(typename detail::pp_if_array<T>::type ptr, std::size_t N)
201199 data[static_cast <std::ptrdiff_t >(N) - 1 - i]);
202200
203201 if (pmemobj_tx_free (*ptr.raw_ptr ()) != 0 )
204- throw pmem::transaction_free_error (
205- " failed to delete persistent memory object " )
206- . with_pmemobj_errormsg ( );
202+ throw detail::exception_with_errormsg<
203+ pmem::transaction_free_error>(
204+ " failed to delete persistent memory object " );
207205}
208206
209207/* *
@@ -248,9 +246,9 @@ delete_persistent(typename detail::pp_if_size_array<T>::type ptr)
248246 data[static_cast <std::ptrdiff_t >(N) - 1 - i]);
249247
250248 if (pmemobj_tx_free (*ptr.raw_ptr ()) != 0 )
251- throw pmem::transaction_free_error (
252- " failed to delete persistent memory object " )
253- . with_pmemobj_errormsg ( );
249+ throw detail::exception_with_errormsg<
250+ pmem::transaction_free_error>(
251+ " failed to delete persistent memory object " );
254252}
255253
256254} /* namespace obj */
0 commit comments