Catch C++ exceptions by const reference

Fixes #2277
This commit is contained in:
Charles Milette
2018-05-19 19:18:26 -04:00
parent b9fd381eee
commit 72c0002b45
22 changed files with 36 additions and 38 deletions

View File

@ -174,7 +174,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
{
args = parser.parse(arguments());
}
catch (ParsingError e)
catch (const ParsingError &e)
{
std::cerr << "CommandLineError: " << e.what() << std::endl;
std::cerr << "Try '%1 -h' to get help on MultiMC's command line parameters."

View File

@ -331,7 +331,7 @@ void UpdateController::installUpdates()
break;
}
}
catch(Exception e)
catch (const Exception &e)
{
qWarning() << "Couldn't read the" << liveCheckFile << "file!";
startFailed = true;

View File

@ -479,7 +479,7 @@ void ExportInstanceDialog::savePackIgnore()
{
FS::write(filename, data);
}
catch (Exception & e)
catch (const Exception &e)
{
qWarning() << e.cause();
}

View File

@ -135,7 +135,7 @@ QString reprocessCommits(QByteArray json)
result += QObject::tr("<p>You can <a href=\"%1\">look at the changes on github</a>.</p>").arg(diff_url);
return result;
}
catch (JSONValidationError & e)
catch (const JSONValidationError &e)
{
qWarning() << "Got an unparseable commit log from github:" << e.what();
qDebug() << json;

View File

@ -109,7 +109,7 @@ static std::unique_ptr <nbt::tag_compound> parseServersDat(const QString& filena
return std::move(pair.second);
}
catch(...)
catch (...)
{
return nullptr;
}
@ -125,7 +125,7 @@ static bool serializeServerDat(const QString& filename, nbt::tag_compound * leve
FS::write(filename, val);
return true;
}
catch(...)
catch (...)
{
return false;
}

View File

@ -200,7 +200,7 @@ bool VersionPage::reloadComponentList()
m_profile->reload(Net::Mode::Online);
return true;
}
catch (Exception &e)
catch (const Exception &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
return false;
@ -269,7 +269,7 @@ void VersionPage::on_moveUpBtn_clicked()
{
m_profile->move(currentRow(), ComponentList::MoveUp);
}
catch (Exception &e)
catch (const Exception &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
}
@ -282,7 +282,7 @@ void VersionPage::on_moveDownBtn_clicked()
{
m_profile->move(currentRow(), ComponentList::MoveDown);
}
catch (Exception &e)
catch (const Exception &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
}

View File

@ -66,7 +66,7 @@ static bool readThemeJson(const QString &path, QPalette &palette, double &fadeAm
fadeAmount = Json::ensureDouble(colorsRoot, "fadeAmount", 0.5, "fade amount");
}
catch(Exception e)
catch (const Exception &e)
{
qWarning() << "Couldn't load theme json: " << e.cause();
return false;
@ -117,7 +117,7 @@ static bool writeThemeJson(const QString &path, const QPalette &palette, double
Json::write(rootObj, path);
return true;
}
catch (Exception e)
catch (const Exception &e)
{
qWarning() << "Failed to write theme json to" << path;
return false;
@ -171,7 +171,7 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QString folder)
// TODO: validate css?
m_styleSheet = QString::fromUtf8(FS::read(cssFilePath));
}
catch(Exception e)
catch (const Exception &e)
{
qWarning() << "Couldn't load css:" << e.cause() << "from" << cssFilePath;
m_styleSheet = baseTheme->appStyleSheet();
@ -185,7 +185,7 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QString folder)
{
FS::write(cssFilePath, m_styleSheet.toUtf8());
}
catch(Exception e)
catch (const Exception &e)
{
qWarning() << "Couldn't write css:" << e.cause() << "to" << cssFilePath;
}