From 09d066108ed83dbe51c8c0e78bee8a461ce53ea1 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Wed, 11 Oct 2023 15:13:13 +0200 Subject: [PATCH] CompilerExplorer: Improve error reporting Displays network errors as disrupting, instead of just sending them to the log. Change-Id: If5a3dbb733f1433dcc2bcd0a52ad12d8ee3b85ef Reviewed-by: Alessandro Portale --- .../compilerexplorer/compilerexplorereditor.cpp | 4 +++- .../compilerexplorersettings.cpp | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/plugins/compilerexplorer/compilerexplorereditor.cpp b/src/plugins/compilerexplorer/compilerexplorereditor.cpp index 7946e92b821..d5003cf8c20 100644 --- a/src/plugins/compilerexplorer/compilerexplorereditor.cpp +++ b/src/plugins/compilerexplorer/compilerexplorereditor.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -464,7 +465,8 @@ void CompilerWidget::doCompile() m_marks.append(mark); } } catch (const std::exception &e) { - qCritical() << "Exception: " << e.what(); + Core::MessageManager::writeDisrupting( + Tr::tr("Failed to compile: \"%1\"").arg(QString::fromUtf8(e.what()))); } }); diff --git a/src/plugins/compilerexplorer/compilerexplorersettings.cpp b/src/plugins/compilerexplorer/compilerexplorersettings.cpp index 8accdbcc214..2cd22aa6414 100644 --- a/src/plugins/compilerexplorer/compilerexplorersettings.cpp +++ b/src/plugins/compilerexplorer/compilerexplorersettings.cpp @@ -8,6 +8,8 @@ #include "api/language.h" #include "api/library.h" +#include + #include #include #include @@ -207,8 +209,9 @@ void CompilerSettings::fillLibraries(const LibrarySelectionAspect::ResultCallbac cachedLibraries(lang) = watcher->result(); fillFromCache(); } catch (const std::exception &e) { - qCritical() << e.what(); - return; + Core::MessageManager::writeDisrupting( + Tr::tr("Failed to fetch libraries: \"%1\"") + .arg(QString::fromUtf8(e.what()))); } }); watcher->setFuture(future); @@ -249,8 +252,9 @@ void SourceSettings::fillLanguageIdModel(const Utils::StringSelectionAspect::Res cachedLanguages() = watcher->result(); fillFromCache(); } catch (const std::exception &e) { - qCritical() << e.what(); - return; + Core::MessageManager::writeDisrupting( + Tr::tr("Failed to fetch languages: \"%1\"") + .arg(QString::fromUtf8(e.what()))); } }); watcher->setFuture(future); @@ -290,8 +294,9 @@ void CompilerSettings::fillCompilerModel(const Utils::StringSelectionAspect::Res fillFromCache(itCache); } catch (const std::exception &e) { - qCritical() << e.what(); - return; + Core::MessageManager::writeDisrupting( + Tr::tr("Failed to fetch compilers: \"%1\"") + .arg(QString::fromUtf8(e.what()))); } }); watcher->setFuture(future);