From 98b8849785dfdf6800c01ac87ae30b15b3521092 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Sat, 6 May 2023 01:23:50 +0200
Subject: [PATCH] Simplify error message for invalid attribute type at reading

---
 src/utils/HDF5.cpp  | 3 +--
 tests/test_HDF5.cpp | 5 +----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/utils/HDF5.cpp b/src/utils/HDF5.cpp
index 4249d3520..a0a57d57d 100644
--- a/src/utils/HDF5.cpp
+++ b/src/utils/HDF5.cpp
@@ -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);
     if (not H5Tequal(attribute_type, type)) {
       std::ostringstream error_msg;
-      error_msg << "invalid type for attribute '" << rang::fgB::yellow << name << rang::fg::reset << "' got "
-                << H5Aget_type(attribute_id) << " expecting " << type;
+      error_msg << "invalid type for attribute '" << rang::fgB::yellow << name << rang::fg::reset << "'";
       throw NormalError(error_msg.str());
     }
 
diff --git a/tests/test_HDF5.cpp b/tests/test_HDF5.cpp
index f84b5f694..bb1ceabe5 100644
--- a/tests/test_HDF5.cpp
+++ b/tests/test_HDF5.cpp
@@ -18,7 +18,6 @@ TEST_CASE("HDF5", "[utils]")
 
   SECTION("create file")
   {
-    std::clog << "filename = " << filename << '\n';
     HDF5::FileId file_id = HDF5::create(filename);
     REQUIRE(file_id >= 0);
     HDF5::close(file_id);
@@ -26,7 +25,6 @@ TEST_CASE("HDF5", "[utils]")
 
   SECTION("open file and add attributes")
   {
-    std::clog << "filename = " << filename << '\n';
     HDF5::FileId file_id = HDF5::openFileRW(filename);
     REQUIRE(file_id >= 0);
 
@@ -56,7 +54,6 @@ TEST_CASE("HDF5", "[utils]")
 
   SECTION("open file ro")
   {
-    std::clog << "filename = " << filename << '\n';
     HDF5::FileId file_id = HDF5::openFileRW(filename);
     REQUIRE(file_id >= 0);
 
@@ -85,7 +82,7 @@ TEST_CASE("HDF5", "[utils]")
     REQUIRE_THROWS_WITH(HDF5::readAttribute<double>(file_id, "invalid attr"),
                         "error: cannot find attribute 'invalid 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);
   }
-- 
GitLab