some additions to pR 1794:

add a special XMLAttributeError class to indicate an error when accessing a missing attribute
in PropertyContainer::Restore make error handling more flexible
This commit is contained in:
wmayer
2018-11-19 19:07:56 +01:00
parent 7216dba2f3
commit ddb20468ad
7 changed files with 71 additions and 19 deletions

View File

@@ -276,13 +276,7 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
try {
// name and type match
if (prop && strcmp(prop->getTypeId().getName(), TypeName.c_str()) == 0) {
prop->Restore(reader);
if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInProperty)) {
Base::Console().Error("Property %s of type %s was subject to a partial restore.\n",PropName.c_str(),TypeName.c_str());
reader.clearPartialRestoreProperty();
}
prop->Restore(reader);
}
// name matches but not the type
else if (prop) {
@@ -293,10 +287,20 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
else {
handleChangedPropertyName(reader, TypeName.c_str(), PropName.c_str());
}
if (reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInProperty)) {
Base::Console().Error("Property %s of type %s was subject to a partial restore.\n",PropName.c_str(),TypeName.c_str());
reader.clearPartialRestoreProperty();
}
}
catch (const Base::XMLParseException&) {
throw; // re-throw
}
catch (const Base::RestoreError &) {
reader.setPartialRestore(true);
reader.clearPartialRestoreProperty();
Base::Console().Error("Property %s of type %s was subject to a partial restore.\n",PropName.c_str(),TypeName.c_str());
}
catch (const Base::Exception &e) {
Base::Console().Error("%s\n", e.what());
}