Skip to content
Snippets Groups Projects
Commit 98b88497 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Simplify error message for invalid attribute type at reading

parent 7b3bdd4b
No related branches found
No related tags found
1 merge request!176Add HDF5 support
...@@ -165,8 +165,7 @@ HDF5::_readAttribute(const HDFId<id_type>& id, const std::string& name, const Da ...@@ -165,8 +165,7 @@ HDF5::_readAttribute(const HDFId<id_type>& id, const std::string& name, const Da
hid_t attribute_type = H5Aget_type(attribute_id); hid_t attribute_type = H5Aget_type(attribute_id);
if (not H5Tequal(attribute_type, type)) { if (not H5Tequal(attribute_type, type)) {
std::ostringstream error_msg; std::ostringstream error_msg;
error_msg << "invalid type for attribute '" << rang::fgB::yellow << name << rang::fg::reset << "' got " error_msg << "invalid type for attribute '" << rang::fgB::yellow << name << rang::fg::reset << "'";
<< H5Aget_type(attribute_id) << " expecting " << type;
throw NormalError(error_msg.str()); throw NormalError(error_msg.str());
} }
......
...@@ -18,7 +18,6 @@ TEST_CASE("HDF5", "[utils]") ...@@ -18,7 +18,6 @@ TEST_CASE("HDF5", "[utils]")
SECTION("create file") SECTION("create file")
{ {
std::clog << "filename = " << filename << '\n';
HDF5::FileId file_id = HDF5::create(filename); HDF5::FileId file_id = HDF5::create(filename);
REQUIRE(file_id >= 0); REQUIRE(file_id >= 0);
HDF5::close(file_id); HDF5::close(file_id);
...@@ -26,7 +25,6 @@ TEST_CASE("HDF5", "[utils]") ...@@ -26,7 +25,6 @@ TEST_CASE("HDF5", "[utils]")
SECTION("open file and add attributes") SECTION("open file and add attributes")
{ {
std::clog << "filename = " << filename << '\n';
HDF5::FileId file_id = HDF5::openFileRW(filename); HDF5::FileId file_id = HDF5::openFileRW(filename);
REQUIRE(file_id >= 0); REQUIRE(file_id >= 0);
...@@ -56,7 +54,6 @@ TEST_CASE("HDF5", "[utils]") ...@@ -56,7 +54,6 @@ TEST_CASE("HDF5", "[utils]")
SECTION("open file ro") SECTION("open file ro")
{ {
std::clog << "filename = " << filename << '\n';
HDF5::FileId file_id = HDF5::openFileRW(filename); HDF5::FileId file_id = HDF5::openFileRW(filename);
REQUIRE(file_id >= 0); REQUIRE(file_id >= 0);
...@@ -85,7 +82,7 @@ TEST_CASE("HDF5", "[utils]") ...@@ -85,7 +82,7 @@ TEST_CASE("HDF5", "[utils]")
REQUIRE_THROWS_WITH(HDF5::readAttribute<double>(file_id, "invalid attr"), REQUIRE_THROWS_WITH(HDF5::readAttribute<double>(file_id, "invalid attr"),
"error: cannot find attribute 'invalid attr'"); "error: cannot find attribute 'invalid attr'");
REQUIRE_THROWS_WITH(HDF5::readAttribute<double>(file_id, "int64_t attr"), REQUIRE_THROWS_WITH(HDF5::readAttribute<double>(file_id, "int64_t attr"),
"error: cannot find attribute 'invalid attr'"); "error: invalid type for attribute 'int64_t attr'");
HDF5::close(file_id); HDF5::close(file_id);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment