19 template <
typename ExceptionType>
20 static inline herr_t
stackWalk(
unsigned n,
const H5E_error2_t* err_desc,
void* client_data) {
21 auto** e_iter =
static_cast<ExceptionType**
>(client_data);
24 const char* major_err = H5Eget_major(err_desc->maj_num);
25 const char* minor_err = H5Eget_minor(err_desc->min_num);
27 std::ostringstream oss;
28 oss <<
'(' << major_err <<
") " << minor_err;
30 H5free_memory((
void*) major_err);
31 H5free_memory((
void*) minor_err);
33 auto* e =
new ExceptionType(oss.str());
34 e->_err_major = err_desc->maj_num;
35 e->_err_minor = err_desc->min_num;
36 (*e_iter)->_next.reset(e);
41 template <
typename ExceptionType>
42 [[noreturn]]
static inline void ToException(
const std::string& prefix_msg) {
43 hid_t err_stack = H5Eget_current_stack();
46 ExceptionType* e_iter = &e;
48 H5Ewalk2(err_stack, H5E_WALK_UPWARD, &HDF5ErrMapper::stackWalk<ExceptionType>, &e_iter);
51 const char* next_err_msg = (e.nextException() != NULL) ? (e.nextException()->what())
54 e.setErrorMsg(prefix_msg +
" " + next_err_msg);
58 throw ExceptionType(prefix_msg +
": Unknown HDF5 error");
Definition H5_definitions.hpp:15
Definition H5Exception_misc.hpp:18
static herr_t stackWalk(unsigned n, const H5E_error2_t *err_desc, void *client_data)
Definition H5Exception_misc.hpp:20
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:42