From 7ffb2bc3c40c3a2798cc6b649d9d81e666d039d4 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 3 Jan 2024 20:34:44 +0400 Subject: [PATCH] Use error messages instead of unhandled exceptions --- apps/launcher/maindialog.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 177d4fe88c..5d558ef38f 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -118,13 +118,14 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog() const auto& userConfigDir = mCfgMgr.getUserConfigPath(); if (!exists(userConfigDir)) { - if (!create_directories(userConfigDir)) + std::error_code ec; + if (!create_directories(userConfigDir, ec)) { - cfgError(tr("Error opening OpenMW configuration file"), + cfgError(tr("Error creating OpenMW configuration directory: code %0").arg(ec.value()), tr("
Could not create directory %0

" - "Please make sure you have the right permissions " - "and try again.
") - .arg(Files::pathToQString(canonical(userConfigDir)))); + "%1
") + .arg(Files::pathToQString(userConfigDir)) + .arg(QString(ec.message().c_str()))); return FirstRunDialogResultFailure; } } @@ -457,13 +458,14 @@ bool Launcher::MainDialog::writeSettings() if (!exists(userPath)) { - if (!create_directories(userPath)) + std::error_code ec; + if (!create_directories(userPath, ec)) { - cfgError(tr("Error creating OpenMW configuration directory"), - tr("
Could not create %0

" - "Please make sure you have the right permissions " - "and try again.
") - .arg(Files::pathToQString(userPath))); + cfgError(tr("Error creating OpenMW configuration directory: code %0").arg(ec.value()), + tr("
Could not create directory %0

" + "%1
") + .arg(Files::pathToQString(userPath)) + .arg(QString(ec.message().c_str()))); return false; } }