diff --git a/src/frontend/helpers/multi_job.cpp b/src/frontend/helpers/multi_job.cpp index 07088a7..ef55178 100644 --- a/src/frontend/helpers/multi_job.cpp +++ b/src/frontend/helpers/multi_job.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "common/logging/log.h" #include "frontend/helpers/multi_job.h" MultiJob::MultiJob(QObject* parent, Core::SDMCImporter& importer_, @@ -45,7 +46,7 @@ void MultiJob::run() { content, eta); if (!execute_func(importer, content, wrapper.Wrap(Callback))) { if (!cancelled) { - failed_contents.emplace_back(content); + failed_contents.emplace_back(content, Common::Logging::GetLastErrors()); } } count++; @@ -62,6 +63,6 @@ void MultiJob::Cancel() { abort_func(importer); } -std::vector MultiJob::GetFailedContents() const { +MultiJob::FailedContentList MultiJob::GetFailedContents() const { return failed_contents; } diff --git a/src/frontend/helpers/multi_job.h b/src/frontend/helpers/multi_job.h index ccf0c8f..84abec6 100644 --- a/src/frontend/helpers/multi_job.h +++ b/src/frontend/helpers/multi_job.h @@ -17,6 +17,8 @@ public: using ExecuteFunc = std::function; using AbortFunc = std::function; + // (content, error log) + using FailedContentList = std::vector>; explicit MultiJob(QObject* parent, Core::SDMCImporter& importer, std::vector contents, ExecuteFunc execute_func, @@ -26,7 +28,7 @@ public: void run() override; void Cancel(); - std::vector GetFailedContents() const; + FailedContentList GetFailedContents() const; signals: /** @@ -48,7 +50,7 @@ private: std::atomic_bool cancelled{false}; Core::SDMCImporter& importer; std::vector contents; - std::vector failed_contents; + FailedContentList failed_contents; ExecuteFunc execute_func; AbortFunc abort_func; }; diff --git a/src/frontend/helpers/simple_job.cpp b/src/frontend/helpers/simple_job.cpp index be49dee..6195ab3 100644 --- a/src/frontend/helpers/simple_job.cpp +++ b/src/frontend/helpers/simple_job.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "common/logging/log.h" #include "frontend/helpers/frontend_common.h" #include "frontend/helpers/rate_limited_progress_dialog.h" #include "frontend/helpers/simple_job.h" @@ -43,8 +44,11 @@ void SimpleJob::StartWithProgressDialog(QWidget* widget) { tr("%1 / %2").arg(ReadableByteSize(current), ReadableByteSize(total))); }); connect(this, &SimpleJob::ErrorOccured, this, [widget, dialog] { - QMessageBox::critical(widget, tr("threeSD"), - tr("Operation failed. Please refer to the log.")); + QMessageBox message_box(QMessageBox::Critical, tr("threeSD"), + tr("Operation failed. Refer to the log for details."), + QMessageBox::Ok, widget); + message_box.setDetailedText(QString::fromStdString(Common::Logging::GetLastErrors())); + message_box.exec(); dialog->hide(); }); connect(this, &SimpleJob::Completed, dialog, &QProgressDialog::hide); diff --git a/src/frontend/import_dialog.cpp b/src/frontend/import_dialog.cpp index 6445f02..e1bc56a 100644 --- a/src/frontend/import_dialog.cpp +++ b/src/frontend/import_dialog.cpp @@ -209,9 +209,12 @@ void ImportDialog::RelistContent() { if (importer->IsGood()) { RepopulateContent(); } else { - QMessageBox::critical( - this, tr("Importer Error"), - tr("Failed to initalize the importer.\nRefer to the log for details.")); + QMessageBox message_box( + QMessageBox::Critical, tr("Importer Error"), + tr("Failed to initalize the importer. Refer to the log for details."), + QMessageBox::Ok, this); + message_box.setDetailedText(QString::fromStdString(Common::Logging::GetLastErrors())); + message_box.exec(); reject(); } }); @@ -713,13 +716,22 @@ void ImportDialog::RunMultiJob(MultiJob* job, std::size_t total_count, u64 total QMessageBox::information(this, tr("threeSD"), tr("All contents done successfully.")); } else { QString list_content; - for (const auto& content : failed_contents) { - list_content.append(QStringLiteral("
  • %1 (%2)
  • ") - .arg(GetContentName(content)) - .arg(GetDisplayGroupName(content))); + QString details; + for (const auto& [content, error] : failed_contents) { + const QString full_name = QStringLiteral("%1 (%2)").arg( + GetContentName(content), GetDisplayGroupName(content)); + + list_content.append(QStringLiteral("
  • %1
  • ").arg(full_name)); + details.append( + QStringLiteral("%1:\n%2\n").arg(full_name, QString::fromStdString(error))); } - QMessageBox::critical(this, tr("threeSD"), - tr("List of failed contents:
      %1
    ").arg(list_content)); + QMessageBox message_box( + QMessageBox::Critical, tr("threeSD"), + tr("List of failed contents (see the log for details):
      %1
    ") + .arg(list_content), + QMessageBox::Ok, this); + message_box.setDetailedText(details); + message_box.exec(); } RelistContent(); diff --git a/src/frontend/utilities.cpp b/src/frontend/utilities.cpp index e25b568..21067f4 100644 --- a/src/frontend/utilities.cpp +++ b/src/frontend/utilities.cpp @@ -258,7 +258,10 @@ void UtilitiesDialog::ShowResult() { if (result) { QMessageBox::information(this, tr("Success"), tr("Operation completed successfully.")); } else { - QMessageBox::critical(this, tr("Error"), - tr("An error occured while performing the operation.")); + QMessageBox message_box(QMessageBox::Critical, tr("threeSD"), + tr("Operation failed. Refer to the log for details."), + QMessageBox::Ok, this); + message_box.setDetailedText(QString::fromStdString(Common::Logging::GetLastErrors())); + message_box.exec(); } }