Error reporting for animations / conditions

Don’t report errors for each condition parse failure, but do 
aggregate them at the animation level in ReaderWriterXML

Sentry-Id: FLIGHTGEAR-DD
This commit is contained in:
James Turner 2021-06-26 16:27:22 +01:00
parent 069483e6d0
commit b50d8e38e6
2 changed files with 23 additions and 10 deletions

View File

@ -537,7 +537,8 @@ readComparison( SGPropertyNode *prop_root,
// REVIEW: Memory Leak - 2,880 bytes in 40 blocks are indirectly lost
SGComparisonCondition * condition = new SGComparisonCondition(type, reverse);
if (node->nChildren() < 2 || node->nChildren() > 3 ) {
throw sg_exception("condition: comparison without two or three children");
throw sg_exception("condition: comparison without two or three children",
{}, {}, false);
}
const SGPropertyNode* left = node->getChild(0),
@ -553,7 +554,8 @@ readComparison( SGPropertyNode *prop_root,
SGExpressiond* exp = SGReadDoubleExpression(prop_root, left->getChild(0));
condition->setLeftDExpression(exp);
} else {
throw sg_exception("Unknown condition comparison left child:" + leftName);
throw sg_exception("Unknown condition comparison left child:" + leftName,
{}, {}, false);
}
}
@ -567,7 +569,8 @@ readComparison( SGPropertyNode *prop_root,
SGExpressiond* exp = SGReadDoubleExpression(prop_root, right->getChild(0));
condition->setRightDExpression(exp);
} else {
throw sg_exception("Unknown condition comparison right child:" + rightName);
throw sg_exception("Unknown condition comparison right child:" + rightName,
{}, {}, false);
}
}
@ -582,7 +585,8 @@ readComparison( SGPropertyNode *prop_root,
SGExpressiond* exp = SGReadDoubleExpression(prop_root, n->getChild(0));
condition->setPrecisionDExpression(exp);
} else {
throw sg_exception("Unknown condition comparison precision child:" + name );
throw sg_exception("Unknown condition comparison precision child:" + name,
{}, {}, false);
}
}

View File

@ -815,6 +815,8 @@ sgLoad3DModel_internal(const SGPath& path,
} // of object-names in the animation
continue;
}
try {
/*
* Setup the model data for the node currently being animated.
*/
@ -822,6 +824,13 @@ sgLoad3DModel_internal(const SGPath& path,
/// OSGFIXME: duh, why not only model?????
SGAnimation::animate(modelData);
} catch (sg_exception& e) {
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::XMLModelLoad,
"Couldn't load animation " + animation_nodes[i]->getNameString()
+ ":" + e.getFormattedMessage(),
modelpath);
throw;
}
}
animationcount += animation_nodes.size();