Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoadChunk: Better Error Message (Type) #1373

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions include/openPMD/RecordComponent.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ inline void RecordComponent::loadChunk(
if( !isSameInteger< T >( getDatatype() ) &&
!isSameFloatingPoint< T >( getDatatype() ) &&
!isSameComplexFloatingPoint< T >( getDatatype() ) )
throw std::runtime_error(
"Type conversion during chunk loading not yet implemented" );
{
std::string const data_type_str = datatypeToString(getDatatype());
std::string const requ_type_str = datatypeToString(determineDatatype<T>());
std::string err_msg = "Type conversion during chunk loading not yet implemented! ";
err_msg += "Data: " + data_type_str + "; Load as: " + requ_type_str;
throw std::runtime_error( err_msg );
}

uint8_t dim = getDimensionality();

Expand Down
8 changes: 6 additions & 2 deletions test/CoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,12 +1230,16 @@ TEST_CASE("load_chunk_wrong_datatype", "[core]")
}
{
Series read("../samples/some_float_value.json", Access::READ_ONLY);

std::string const err_msg =
"Type conversion during chunk loading not yet implemented! "
"Data: FLOAT; Load as: DOUBLE";

REQUIRE_THROWS_WITH(
read.iterations[0]
.meshes["rho"][RecordComponent::SCALAR]
.loadChunk<double>({0}, {10}),
Catch::Equals(
"Type conversion during chunk loading not yet implemented"));
Catch::Equals(err_msg));
}
}

Expand Down