typeCast.cpp: do not report index in exception message for scalars

This commit is contained in:
Matej Sekoranja
2013-11-22 10:31:21 +01:00
parent 8e63fc8b25
commit 86306740be

View File

@@ -36,10 +36,16 @@ static void castVTyped(size_t count, void *draw, const void *sraw)
++dest; ++src;
}
} catch (std::exception& ex) {
std::ostringstream os;
os << "failed to parse element at index " << (src - (FROM*)sraw);
os << ": " << ex.what();
throw std::runtime_error(os.str());
// do not report index for scalars (or arrays with one element)
if (count > 1)
{
std::ostringstream os;
os << "failed to parse element at index " << (src - (FROM*)sraw);
os << ": " << ex.what();
throw std::runtime_error(os.str());
}
else
throw;
}
}