From 86306740be67d786737ae9e9c799a47dbb278c7f Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Fri, 22 Nov 2013 10:31:21 +0100 Subject: [PATCH] typeCast.cpp: do not report index in exception message for scalars --- pvDataApp/misc/typeCast.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pvDataApp/misc/typeCast.cpp b/pvDataApp/misc/typeCast.cpp index 88c540d..5bda363 100644 --- a/pvDataApp/misc/typeCast.cpp +++ b/pvDataApp/misc/typeCast.cpp @@ -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; } }