Skip to content

Commit

Permalink
Improved error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Dafarra committed Dec 20, 2024
1 parent fefe428 commit 48467b2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions include/matioCpp/impl/EigenConversions.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ namespace matioCpp
template <typename type>
SlicingInfo computeSlicingInfo(const matioCpp::MultiDimensionalArray<type>& input, const std::vector<int>& slice)
{
std::string errorPrefix = "[ERROR][matioCpp::to_eigen] ";

using index_type = typename matioCpp::MultiDimensionalArray<type>::index_type;
SlicingInfo info;

const auto& dimensions = input.dimensions();

if (slice.size() != dimensions.size())
{
std::cerr << "The number of slices must be equal to the number of dimensions of the input MultiDimensionalArray" << std::endl;
std::cerr << errorPrefix << "The number of slices must be equal to the number of dimensions of the input MultiDimensionalArray" << std::endl;
assert(false);
return info;
}
Expand All @@ -45,7 +47,7 @@ namespace matioCpp
{
if (slice[i] >= dimensions(i))
{
std::cerr << "The slice is larger than the dimension of the input MultiDimensionalArray" << std::endl;
std::cerr << errorPrefix << "The slice is larger than the dimension of the input MultiDimensionalArray" << std::endl;
assert(false);
return SlicingInfo();
}
Expand All @@ -65,7 +67,7 @@ namespace matioCpp
}
else
{
std::cerr << "Only at most two free dimensions are allowed" << std::endl;
std::cerr << errorPrefix << "Only at most two free dimensions are allowed" << std::endl;
assert(false);
return SlicingInfo();
}
Expand Down

0 comments on commit 48467b2

Please sign in to comment.