Fix FreeCAD#19588

This commit is contained in:
Florian Foinant-Willig
2025-03-17 08:45:29 +01:00
committed by Benjamin Nauck
parent ae08c322b2
commit 756e3789ce
3 changed files with 34 additions and 2 deletions

View File

@@ -2186,6 +2186,7 @@ bool Document::saveToFile(const char* filename) const
// open extra scope to close ZipWriter properly
{
Base::ofstream file(tmp, std::ios::out | std::ios::binary);
Base::ZipWriter writer(file);
if (!file.is_open()) {
throw Base::FileException("Failed to open file", tmp);
@@ -2211,9 +2212,12 @@ bool Document::saveToFile(const char* filename) const
// write additional files
writer.writeFiles();
if (writer.hasErrors()) {
throw Base::FileException("Failed to write all data to file", tmp);
// retrieve Writer error strings
std::stringstream message;
message << "Failed to write all data to file ";
message << writer.getErrors().front();
throw Base::FileException(message.str().c_str(), tmp);
}
GetApplication().signalSaveDocument(*this);