From 9d8546b841a10709de4dbc32c50be5ebfef913bb Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Mon, 19 Feb 2024 13:52:24 -0500 Subject: [PATCH] BUG: Rework API for DataMap and DeepCopy in DataObject. We need to be able to report errors back up the call tree if possible. Signed-off-by: Michael Jackson --- src/simplnx/DataStructure/AttributeMatrix.cpp | 5 ++++- src/simplnx/DataStructure/DataMap.cpp | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/simplnx/DataStructure/AttributeMatrix.cpp b/src/simplnx/DataStructure/AttributeMatrix.cpp index 4e4aae71d5..faf982a733 100644 --- a/src/simplnx/DataStructure/AttributeMatrix.cpp +++ b/src/simplnx/DataStructure/AttributeMatrix.cpp @@ -96,7 +96,10 @@ bool AttributeMatrix::canInsert(const DataObject* obj) const const usize totalTuples = std::accumulate(m_TupleShape.cbegin(), m_TupleShape.cend(), static_cast(1), std::multiplies<>()); const usize incomingTupleCount = std::accumulate(arrayTupleShape.cbegin(), arrayTupleShape.cend(), static_cast(1), std::multiplies<>()); - + if(totalTuples != incomingTupleCount) + { + std::cout << "AttributeMatrix: CanInsert() Failed with object " << obj->getName() << ". totalTuples=" << totalTuples << " incomingTupleCount=" << incomingTupleCount << "\n"; + } return (totalTuples == incomingTupleCount); } diff --git a/src/simplnx/DataStructure/DataMap.cpp b/src/simplnx/DataStructure/DataMap.cpp index be0fed6187..a7dd017f1d 100644 --- a/src/simplnx/DataStructure/DataMap.cpp +++ b/src/simplnx/DataStructure/DataMap.cpp @@ -30,6 +30,10 @@ DataMap DataMap::deepCopy(const DataPath& parentCopyPath) const { const auto& dataObj = m_Map.at(key); const auto copy = dataObj->deepCopy(parentCopyPath.createChildPath(dataObj->getName())); + if(copy == nullptr) + { + throw std::runtime_error(fmt::format("A deep copy request for parent '{}' failed on child object '{}' ", parentCopyPath.toString(), dataObj->getName())); + } dataMap.m_Map[key] = copy; } return dataMap;