1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-05-17 19:41:28 +00:00

Use error messages instead of unhandled exceptions

This commit is contained in:
Andrei Kortunov 2024-01-03 20:34:44 +04:00
parent 9cbe82ac7b
commit 7ffb2bc3c4

View file

@ -118,13 +118,14 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
const auto& userConfigDir = mCfgMgr.getUserConfigPath(); const auto& userConfigDir = mCfgMgr.getUserConfigPath();
if (!exists(userConfigDir)) 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("<br><b>Could not create directory %0</b><br><br>" tr("<br><b>Could not create directory %0</b><br><br>"
"Please make sure you have the right permissions " "%1<br>")
"and try again.<br>") .arg(Files::pathToQString(userConfigDir))
.arg(Files::pathToQString(canonical(userConfigDir)))); .arg(QString(ec.message().c_str())));
return FirstRunDialogResultFailure; return FirstRunDialogResultFailure;
} }
} }
@ -457,13 +458,14 @@ bool Launcher::MainDialog::writeSettings()
if (!exists(userPath)) if (!exists(userPath))
{ {
if (!create_directories(userPath)) std::error_code ec;
if (!create_directories(userPath, ec))
{ {
cfgError(tr("Error creating OpenMW configuration directory"), cfgError(tr("Error creating OpenMW configuration directory: code %0").arg(ec.value()),
tr("<br><b>Could not create %0</b><br><br>" tr("<br><b>Could not create directory %0</b><br><br>"
"Please make sure you have the right permissions " "%1<br>")
"and try again.<br>") .arg(Files::pathToQString(userPath))
.arg(Files::pathToQString(userPath))); .arg(QString(ec.message().c_str())));
return false; return false;
} }
} }