Skip to content

Commit 4ffcfb7

Browse files
authored
Merge pull request #208 from serge-sans-paille/feature/better-error-report-pycontainer
Better error report when facing dimension mismatch
2 parents 1f70cf3 + dfb2dce commit 4ffcfb7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/xtensor-python/pycontainer.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <cmath>
1414
#include <functional>
1515
#include <numeric>
16+
#include <sstream>
1617

1718
#include "pybind11/complex.h"
1819
#include "pybind11/pybind11.h"
@@ -356,7 +357,10 @@ namespace xt
356357
{
357358
if(new_dim != N)
358359
{
359-
throw std::runtime_error("Dims not matching.");
360+
std::ostringstream err_msg;
361+
err_msg << "Invalid conversion to pycontainer, expecting a container of dimension "
362+
<< N << ", got a container of dimension " << new_dim << ".";
363+
throw std::runtime_error(err_msg.str());
360364
}
361365
return new_dim == N;
362366
}

0 commit comments

Comments
 (0)