From 43e7be902c03f54021391e13fb00b8796bd7275d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 18 Jan 2025 22:49:43 +1000 Subject: [PATCH] Misc: Add missing error reporting to a couple of WriteBinaryFiles() --- src/core/achievements.cpp | 5 +++-- src/duckstation-qt/qthost.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/achievements.cpp b/src/core/achievements.cpp index 8340a517d..04109778c 100644 --- a/src/core/achievements.cpp +++ b/src/core/achievements.cpp @@ -381,9 +381,10 @@ void Achievements::DownloadImage(std::string url, std::string cache_path) return; } - if (!FileSystem::WriteBinaryFile(cache_path.c_str(), data.data(), data.size())) + Error write_error; + if (!FileSystem::WriteBinaryFile(cache_path.c_str(), data, &write_error)) { - ERROR_LOG("Failed to write badge image to '{}'", cache_path); + ERROR_LOG("Failed to write badge image to '{}': {}", cache_path, write_error.GetDescription()); return; } diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index fd609faa0..2ead351cd 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -348,12 +348,15 @@ bool QtHost::DownloadFile(QWidget* parent, const QString& title, std::string url // Directory may not exist. Create it. const std::string directory(Path::GetDirectory(path)); + Error error; if ((!directory.empty() && !FileSystem::DirectoryExists(directory.c_str()) && - !FileSystem::CreateDirectory(directory.c_str(), true)) || - !FileSystem::WriteBinaryFile(path, data.data(), data.size())) + !FileSystem::CreateDirectory(directory.c_str(), true, &error)) || + !FileSystem::WriteBinaryFile(path, data, &error)) { QMessageBox::critical(parent, qApp->translate("QtHost", "Error"), - qApp->translate("QtHost", "Failed to write '%1'.").arg(QString::fromUtf8(path))); + qApp->translate("QtHost", "Failed to write '%1':\n%2") + .arg(QString::fromUtf8(path)) + .arg(QString::fromUtf8(error.GetDescription()))); return false; }