UESaveFile: add more error messages.

This commit is contained in:
Guillaume Jacquemin 2021-09-23 18:25:28 +02:00
parent d3d065c945
commit 1caa472833
1 changed files with 7 additions and 0 deletions

View File

@ -61,6 +61,7 @@ auto UESaveFile::saveToFile() -> bool {
BinaryWriter writer{_filepath + ".tmp"};
if(!writer.open()) {
_lastError = "Couldn't open the file for saving.";
return false;
}
@ -73,12 +74,14 @@ auto UESaveFile::saveToFile() -> bool {
!writer.writeUnsignedInt(_engineVersion.build) ||
!writer.writeUEString(_engineVersion.buildId))
{
_lastError = "Couldn't write the header.";
return false;
}
if(!writer.writeUnsignedInt(_customFormatVersion) ||
!writer.writeUnsignedInt(_customFormatData.size()))
{
_lastError = "Couldn't write the header.";
return false;
}
@ -86,21 +89,25 @@ auto UESaveFile::saveToFile() -> bool {
if(!writer.writeStaticArray(Containers::StaticArrayView<16, const char>{_customFormatData[i].id}) ||
!writer.writeUnsignedInt(_customFormatData[i].value))
{
_lastError = "Couldn't write the header.";
return false;
}
}
if(!writer.writeUEString(_saveType)) {
_lastError = "Couldn't write the header.";
return false;
}
for(auto& prop : _properties) {
UnsignedLong bytes_written = 0;
if(!_propSerialiser.write(prop, bytes_written, writer)) {
_lastError = "Couldn't write the property " + *prop->name + " to the array.";
return false;
}
if(!writer.flushToFile()) {
_lastError = "Couldn't write the property " + *prop->name + " to the file.";
return false;
}
}