From c25ebdd1c893e2677f5c6b7517f80d7802d1b089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 2 Aug 2022 08:29:40 +0200 Subject: [PATCH] Provide more info in case of write failure --- src/openrct2/core/FileStream.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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();