Skip to content

Commit

Permalink
Check more HDF5 return values for error
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAce committed Oct 8, 2021
1 parent 0e6b035 commit bfa7de8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions include/h5pp/details/h5ppHdf5.h
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,11 @@ namespace h5pp::hdf5 {
if(H5Tequal(type, H5T_NATIVE_SCHAR)) return getCppType<signed char>();
if(H5Tequal(type, H5T_NATIVE_UCHAR)) return getCppType<unsigned char>();
}else if (h5class == H5T_COMPOUND){
auto h5nmemb = H5Tget_nmembers(type);
if(h5size == 8ul*h5nmemb){
auto nmembers = H5Tget_nmembers(type);
if(nmembers < 0)
throw std::runtime_error(h5pp::format("Failed to read nmembers for type"));
auto nmembers_ul = static_cast<size_t>(nmembers);
if(h5size == 8ul*nmembers_ul){
if (H5T_COMPLEX<int8_t>::equal(type)) return getCppType<std::complex<int8_t>>();
if (H5T_COMPLEX<uint8_t>::equal(type)) return getCppType<std::complex<uint8_t>>();
if (H5T_COMPLEX<int_fast8_t>::equal(type)) return getCppType<std::complex<int_fast8_t>>();
Expand Down
12 changes: 9 additions & 3 deletions include/h5pp/details/h5ppScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,16 @@ namespace h5pp::scan {
if(dims.size() != 1) throw std::logic_error("Tables can only have rank 1");
info.numRecords = dims[0];
}
if(not info.numFields) info.numFields = static_cast<size_t>(H5Tget_nmembers(info.h5Type.value()));
if(not info.numFields) {
auto nmembers = H5Tget_nmembers(info.h5Type.value());
if(nmembers < 0)
throw std::runtime_error(h5pp::format("Failed to read nmembers for h5Type on table [{}]", info.tablePath.value()));
info.numFields = static_cast<hsize_t>(nmembers);
}
if(not info.tableTitle) {
char table_title[255];
H5TBAget_title(info.h5Dset.value(), table_title);
char table_title[255];
herr_t err = H5TBAget_title(info.h5Dset.value(), table_title);
if(err < 0) throw std::runtime_error(h5pp::format("Failed to read title for table [{}]", info.tablePath.value()));
info.tableTitle = table_title;
}

Expand Down

0 comments on commit bfa7de8

Please sign in to comment.