diff --git a/src/openrct2/core/FileStream.cpp b/src/openrct2/core/FileStream.cpp index b95b220fe5..bfe8ee70bc 100644 --- a/src/openrct2/core/FileStream.cpp +++ b/src/openrct2/core/FileStream.cpp @@ -184,9 +184,11 @@ namespace OpenRCT2 { return; } - if (fwrite(buffer, static_cast(length), 1, _file) != 1) + if (auto count = fwrite(buffer, static_cast(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();