From 1caa472833e8a643a287dc8a2eb53a666af937d4 Mon Sep 17 00:00:00 2001 From: William JCM Date: Thu, 23 Sep 2021 18:25:28 +0200 Subject: [PATCH] UESaveFile: add more error messages. --- src/UESaveFile/UESaveFile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/UESaveFile/UESaveFile.cpp b/src/UESaveFile/UESaveFile.cpp index dd87b35..16e6310 100644 --- a/src/UESaveFile/UESaveFile.cpp +++ b/src/UESaveFile/UESaveFile.cpp @@ -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; } }