Skip to content

Commit dfb2dce

Browse files
Better error report when facing dimension mismatch
1 parent c19dae6 commit dfb2dce

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
@@ -12,6 +12,7 @@
1212
#include <cmath>
1313
#include <functional>
1414
#include <numeric>
15+
#include <sstream>
1516

1617
#include "pybind11/complex.h"
1718
#include "pybind11/pybind11.h"
@@ -338,7 +339,10 @@ namespace xt
338339
{
339340
if(new_dim != N)
340341
{
341-
throw std::runtime_error("Dims not matching.");
342+
std::ostringstream err_msg;
343+
err_msg << "Invalid conversion to pycontainer, expecting a container of dimension "
344+
<< N << ", got a container of dimension " << new_dim << ".";
345+
throw std::runtime_error(err_msg.str());
342346
}
343347
return new_dim == N;
344348
}

0 commit comments

Comments
 (0)