Provide error message when loading a speckfile that does not contain only numbers (closes #1903)

This commit is contained in:
Alexander Bock
2022-03-18 15:50:01 +01:00
parent f29dee2fe3
commit 86dcff62c4
2 changed files with 23 additions and 1 deletions

View File

@@ -315,10 +315,27 @@ Dataset loadFile(std::filesystem::path path, SkipAllZeroLines skipAllZeroLines)
str >> entry.position.x >> entry.position.y >> entry.position.z;
allZero &= (entry.position == glm::vec3(0.0));
if (!str.good()) {
throw ghoul::RuntimeError(fmt::format(
"Error loading position information out of data line {} in file {}. "
"Value was not a number",
res.entries.size(), path
));
}
entry.data.resize(nDataValues);
for (int i = 0; i < nDataValues; i += 1) {
str >> entry.data[i];
bool isGood = str.good();
allZero &= (entry.data[i] == 0.0);
if (!str.good()) {
throw ghoul::RuntimeError(fmt::format(
"Error loading data value {} out of data line {} in file {}. "
"Value was not a number",
i, res.entries.size(), path
));
}
}
if (skipAllZeroLines && allZero) {

View File

@@ -65,7 +65,12 @@ void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) {
);
}
node->initialize();
try {
node->initialize();
}
catch (const ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
std::lock_guard g(_mutex);
_initializedNodes.push_back(node);
_initializingNodes.erase(node);