Provide more info in case of write failure

This commit is contained in:
Michał Janiszewski 2022-08-02 08:29:40 +02:00
parent 15fad6b979
commit c25ebdd1c8
1 changed files with 4 additions and 2 deletions

View File

@ -184,9 +184,11 @@ namespace OpenRCT2
{
return;
}
if (fwrite(buffer, static_cast<size_t>(length), 1, _file) != 1)
if (auto count = fwrite(buffer, static_cast<size_t>(length), 1, _file); count != 1)
{
throw IOException("Unable to write to file.");
std::string error = "Unable to write " + std::to_string(length) + " bytes to file. Count = " + std::to_string(count)
+ ", errno = " + std::to_string(errno);
throw IOException(error);
}
uint64_t position = GetPosition();