diff --git a/src/Base/Reader.cpp b/src/Base/Reader.cpp index 507186db52..5580d0897a 100644 --- a/src/Base/Reader.cpp +++ b/src/Base/Reader.cpp @@ -330,12 +330,25 @@ void Base::XMLReader::readFiles(zipios::ZipInputStream &zipstream) const // no file name for the current entry in the zip was registered. if (jt != FileList.end()) { try { - Base::Reader reader(zipstream, jt->FileName, FileVersion); - jt->Object->RestoreDocFile(reader); - if (reader.getLocalReader()) - reader.getLocalReader()->readFiles(zipstream); - } - catch(...) { + Base::Reader reader(zipstream, jt->FileName, FileVersion); + + try{ + jt->Object->RestoreDocFile(reader); + }catch (const Base::XMLParseException& e) { + //For some reason catching this error in RestoreDocFile(reader) its working but + //still need to catch it here again. Im not sure how its that possible since its from a constructor. + + //It comes from trying to read "ProjectUnitSystem" from GuiDocument.xml and reaching EndDocument + //because was not found. + //I dont think EndDocument should throw error anyway. + if(e.getMessage() != "End of document reached"){ + throw; + } + } + + if (reader.getLocalReader()) + reader.getLocalReader()->readFiles(zipstream); + }catch(...) { // For any exception we just continue with the next file. // It doesn't matter if the last reader has read more or // less data than the file size would allow. diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 3bbfc42b70..703856a99c 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1480,14 +1480,15 @@ void Document::RestoreDocFile(Base::Reader &reader) Base::Console().Error("%s\n", e.what()); } } - try{ - localreader->readElement("ProjectUnitSystem"); - int US = localreader->getAttributeAsInteger("US"); - int ignore = localreader->getAttributeAsInteger("ignore"); - d->projectUnitSystem = US; - d->projectUnitSystemIgnore = ignore; - }catch (const Base::XMLParseException& e) { - Base::Console().Error("ProjectUnitSystem not found\n"); + + try{ + localreader->readElement("ProjectUnitSystem"); + int US = localreader->getAttributeAsInteger("US"); + int ignore = localreader->getAttributeAsInteger("ignore"); + d->projectUnitSystem = US; + d->projectUnitSystemIgnore = ignore; + }catch (const Base::XMLParseException& e) { + Base::Console().Warning("ProjectUnitSystem not found: %s\n", e.getMessage().c_str()); } }