diff --git a/kmymoney/converter/mymoneystatementreader.cpp b/kmymoney/converter/mymoneystatementreader.cpp
--- a/kmymoney/converter/mymoneystatementreader.cpp
+++ b/kmymoney/converter/mymoneystatementreader.cpp
@@ -531,7 +531,7 @@
qDebug("Processing transactions done (%s)", qPrintable(d->m_account.name()));
} catch (const MyMoneyException &e) {
- if (e.what() == "USERABORT")
+ if (e.what().contains("USERABORT"))
m_userAbort = true;
else
qDebug("Caught exception from processTransactionEntry() not caused by USERABORT: %s", qPrintable(e.what()));
@@ -547,7 +547,7 @@
signalProgress(0, s.m_listPrices.count(), "Importing Statement ...");
KMyMoneyUtils::processPriceList(s);
} catch (const MyMoneyException &e) {
- if (e.what() == "USERABORT")
+ if (e.what().contains("USERABORT"))
m_userAbort = true;
else
qDebug("Caught exception from processPriceEntry() not caused by USERABORT: %s", qPrintable(e.what()));
@@ -998,7 +998,7 @@
// if we did not find a matching payee, we throw an exception and try to create it
if (payeeid.isEmpty())
- throw MYMONEYEXCEPTION("payee not matched");
+ throw MYMONEYEXCEPTION(QStringLiteral("payee not matched"));
s1.setPayeeId(payeeid);
} catch (const MyMoneyException &) {
@@ -1085,7 +1085,7 @@
payee.setDefaultAccountId(accountId);
} else if (result != QDialog::Rejected) {
//add cancel button? and throw exception like below
- throw MYMONEYEXCEPTION("USERABORT");
+ throw MYMONEYEXCEPTION(QStringLiteral("USERABORT"));
}
}
@@ -1097,8 +1097,7 @@
s1.setPayeeId(payeeid);
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(0, i18n("Unable to add payee/receiver"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(nullptr, i18n("Unable to add payee/receiver"), e.what());
}
@@ -1106,7 +1105,7 @@
s1.setPayeeId(QString());
} else {
- throw MYMONEYEXCEPTION("USERABORT");
+ throw MYMONEYEXCEPTION(QStringLiteral("USERABORT"));
}
}
@@ -1300,7 +1299,7 @@
int result = KMessageBox::warningContinueCancel(0, message);
if (result == KMessageBox::Cancel)
- throw MYMONEYEXCEPTION("USERABORT");
+ throw MYMONEYEXCEPTION(QStringLiteral("USERABORT"));
}
}
@@ -1412,7 +1411,7 @@
}
} else {
if (accountSelect->aborted())
- //throw MYMONEYEXCEPTION("USERABORT");
+ //throw MYMONEYEXCEPTION(QStringLiteral("USERABORT"));
done = true;
else
KMessageBox::error(0, QLatin1String("") + i18n("You must select an account, create a new one, or press the Abort button.") + QLatin1String(""));
@@ -1519,11 +1518,11 @@
matcher.match(torig, matchedSplit, importedTransaction, importedSplit);
d->transactionsMatched++;
- } catch (const MyMoneyException &e) {
+ } catch (const MyMoneyException &) {
// make sure we get rid of the editor before
// the KEnterScheduleDlg is destroyed
delete editor;
- throw e; // rethrow
+ throw; // rethrow
}
}
// delete the editor
diff --git a/kmymoney/converter/mymoneytemplate.cpp b/kmymoney/converter/mymoneytemplate.cpp
--- a/kmymoney/converter/mymoneytemplate.cpp
+++ b/kmymoney/converter/mymoneytemplate.cpp
@@ -465,10 +465,10 @@
if (qfile.open(QIODevice::WriteOnly)) {
saveToLocalFile(&qfile);
if (!qfile.commit()) {
- throw MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'", filename));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to write changes to '%1'").arg(filename));
}
} else {
- throw MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'", filename));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to write changes to '%1'").arg(filename));
}
} else {
QTemporaryFile tmpfile;
@@ -477,17 +477,17 @@
if (qfile.open(QIODevice::WriteOnly)) {
saveToLocalFile(&qfile);
if (!qfile.commit()) {
- throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'", url.toDisplayString()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to upload to '%1'").arg(url.toDisplayString()));
}
} else {
- throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'", url.toDisplayString()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to upload to '%1'").arg(url.toDisplayString()));
}
int permission = -1;
QFile file(tmpfile.fileName());
file.open(QIODevice::ReadOnly);
KIO::StoredTransferJob *putjob = KIO::storedPut(file.readAll(), url, permission, KIO::JobFlag::Overwrite);
if (!putjob->exec()) {
- throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'.
%2", url.toDisplayString(), putjob->errorString()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to upload to '%1'.
%2").arg(url.toDisplayString(), putjob->errorString()));
}
file.close();
}
diff --git a/kmymoney/converter/transactionmatchfinder.cpp b/kmymoney/converter/transactionmatchfinder.cpp
--- a/kmymoney/converter/transactionmatchfinder.cpp
+++ b/kmymoney/converter/transactionmatchfinder.cpp
@@ -61,7 +61,7 @@
MyMoneySplit TransactionMatchFinder::getMatchedSplit() const
{
if (matchedSplit.isNull()) {
- throw MYMONEYEXCEPTION(i18n("Internal error - no matching splits"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Internal error - no matching splits"));
}
return *matchedSplit;
@@ -70,7 +70,7 @@
MyMoneyTransaction TransactionMatchFinder::getMatchedTransaction() const
{
if (matchedTransaction.isNull()) {
- throw MYMONEYEXCEPTION(i18n("Internal error - no matching transactions"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Internal error - no matching transactions"));
}
return *matchedTransaction;
@@ -79,7 +79,7 @@
MyMoneySchedule TransactionMatchFinder::getMatchedSchedule() const
{
if (matchedSchedule.isNull()) {
- throw MYMONEYEXCEPTION(i18n("Internal error - no matching schedules"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Internal error - no matching schedules"));
}
return *matchedSchedule;
diff --git a/kmymoney/converter/webpricequote.cpp b/kmymoney/converter/webpricequote.cpp
--- a/kmymoney/converter/webpricequote.cpp
+++ b/kmymoney/converter/webpricequote.cpp
@@ -1051,7 +1051,7 @@
QRegularExpression formatrex("%([mdy]+)(\\W+)%([mdy]+)(\\W+)%([mdy]+)", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match;
if (m_format.indexOf(formatrex, 0, &match) == -1) {
- throw MYMONEYEXCEPTION("Invalid format string");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid format string"));
}
QStringList formatParts;
@@ -1080,7 +1080,7 @@
inputrex.setPattern("(\\w+)\\W+(\\w+)\\W+(\\w+)");
if (_in.indexOf(inputrex, 0, &match) == -1) {
- throw MYMONEYEXCEPTION("Invalid input string");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid input string"));
}
QStringList scannedParts;
@@ -1106,7 +1106,7 @@
if ((*it_scanned).indexOf(digitrex, 0, &match) != -1)
day = match.captured(1).toUInt(&ok);
if (!ok || day > 31)
- throw MYMONEYEXCEPTION(QString("Invalid day entry: %1").arg(*it_scanned));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid day entry: %1").arg(*it_scanned));
break;
case 'm':
month = (*it_scanned).toUInt(&ok);
@@ -1143,18 +1143,18 @@
}
if (month < 1 || month > 12)
- throw MYMONEYEXCEPTION(QString("Invalid month entry: %1").arg(*it_scanned));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid month entry: %1").arg(*it_scanned));
break;
case 'y':
if (_strict && (*it_scanned).length() != (*it_format).length())
- throw MYMONEYEXCEPTION(QString("Length of year (%1) does not match expected length (%2).")
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Length of year (%1) does not match expected length (%2).")
.arg(*it_scanned, *it_format));
year = (*it_scanned).toUInt(&ok);
if (!ok)
- throw MYMONEYEXCEPTION(QString("Invalid year entry: %1").arg(*it_scanned));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid year entry: %1").arg(*it_scanned));
//
// 2-digit year case
@@ -1172,11 +1172,11 @@
}
if (year < 1900)
- throw MYMONEYEXCEPTION(QString("Invalid year (%1)").arg(year));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid year (%1)").arg(year));
break;
default:
- throw MYMONEYEXCEPTION("Invalid format character");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid format character"));
}
++it_scanned;
@@ -1184,7 +1184,7 @@
}
QDate result(year, month, day);
if (! result.isValid())
- throw MYMONEYEXCEPTION(QString("Invalid date (yr%1 mo%2 dy%3)").arg(year).arg(month).arg(day));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid date (yr%1 mo%2 dy%3)").arg(year).arg(month).arg(day));
return result;
}
diff --git a/kmymoney/dialogs/transactionmatcher.cpp b/kmymoney/dialogs/transactionmatcher.cpp
--- a/kmymoney/dialogs/transactionmatcher.cpp
+++ b/kmymoney/dialogs/transactionmatcher.cpp
@@ -98,11 +98,11 @@
// allow matching two manual transactions
if ((!allowImportedTransactions && tm.isImported()) || sm.isMatched())
- throw MYMONEYEXCEPTION(i18n("First transaction does not match requirement for matching"));
+ throw MYMONEYEXCEPTION(QStringLiteral("First transaction does not match requirement for matching"));
// verify that the amounts are the same, otherwise we should not be matching!
if (sm.shares() != si.shares()) {
- throw MYMONEYEXCEPTION(i18n("Splits for %1 have conflicting values (%2,%3)", d->m_account.name(), MyMoneyUtils::formatMoney(sm.shares(), d->m_account, sec), MyMoneyUtils::formatMoney(si.shares(), d->m_account, sec)));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Splits for %1 have conflicting values (%2,%3)").arg(d->m_account.name(), MyMoneyUtils::formatMoney(sm.shares(), d->m_account, sec), MyMoneyUtils::formatMoney(si.shares(), d->m_account, sec)));
}
// ipwizard: I took over the code to keep the bank id found in the endMatchTransaction
@@ -116,8 +116,7 @@
tm.modifySplit(sm);
}
} catch (const MyMoneyException &e) {
- QString estr = e.what();
- throw MYMONEYEXCEPTION(i18n("Unable to match all splits (%1)", estr));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to match all splits (%1)").arg(e.what()));
}
}
//
diff --git a/kmymoney/kmymoney.cpp b/kmymoney/kmymoney.cpp
--- a/kmymoney/kmymoney.cpp
+++ b/kmymoney/kmymoney.cpp
@@ -470,7 +470,7 @@
// add new levels above. Don't forget to increase currentFixVersion() for all
// the storage backends this fix applies to
default:
- throw MYMONEYEXCEPTION(i18n("Unknown fix level in input file"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown fix level in input file"));
}
}
ft.commit();
@@ -684,7 +684,7 @@
try {
if (!(*it).currencyId().isEmpty() || (*it).currencyId().length() != 0)
cid = MyMoneyFile::instance()->currency((*it).currencyId()).id();
- } catch (const MyMoneyException& e) {
+ } catch (const MyMoneyException &e) {
qDebug() << QLatin1String("Account") << (*it).id() << (*it).name() << e.what();
}
@@ -766,7 +766,7 @@
haveAt = false;
isEncrypted = true;
} else {
- throw MYMONEYEXCEPTION(QString::fromLatin1("%1").arg(i18n("GPG is not available for decryption of file %1", fileName)));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("GPG is not available for decryption of file %1").arg(fileName));
}
} else {
// we can't use file directly, as we delete qfile later on
@@ -808,7 +808,7 @@
if ((magic0 == MAGIC_0_50 && magic1 == MAGIC_0_51) ||
magic0 < 30) {
// we do not support this file format anymore
- throw MYMONEYEXCEPTION(QString::fromLatin1("%1").arg(i18n("File %1 contains the old binary format used by KMyMoney. Please use an older version of KMyMoney (0.8.x) that still supports this format to convert it to the new XML based format.", fileName)));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("File %1 contains the old binary format used by KMyMoney. Please use an older version of KMyMoney (0.8.x) that still supports this format to convert it to the new XML based format.").arg(fileName));
}
// Scan the first 70 bytes to see if we find something
@@ -973,7 +973,7 @@
auto rc = true;
try {
if (! url.isValid()) {
- throw MYMONEYEXCEPTION(i18n("Malformed URL '%1'", url.url()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Malformed URL '%1'").arg(url.url()));
}
if (url.scheme() == QLatin1String("sql")) {
@@ -988,7 +988,7 @@
}
if(!pluginFound)
- throw MYMONEYEXCEPTION(i18n("Couldn't find suitable plugin to save your storage."));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Couldn't find suitable plugin to save your storage."));
} else if (url.isLocalFile()) {
filename = url.toLocalFile();
@@ -999,7 +999,7 @@
}
saveToLocalFile(filename, storageWriter.get(), plaintext, keyList);
} catch (const MyMoneyException &) {
- throw MYMONEYEXCEPTION(i18n("Unable to write changes to '%1'", filename));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to write changes to '%1'").arg(filename));
}
} else {
@@ -1013,7 +1013,7 @@
file.open(QIODevice::ReadOnly);
KIO::StoredTransferJob *putjob = KIO::storedPut(file.readAll(), url, permission, KIO::JobFlag::Overwrite);
if (!putjob->exec()) {
- throw MYMONEYEXCEPTION(i18n("Unable to upload to '%1'.
%2", url.toDisplayString(), putjob->errorString()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to upload to '%1'.
%2").arg(url.toDisplayString(), putjob->errorString()));
}
file.close();
}
@@ -1130,7 +1130,7 @@
ft.commit();
if (!device || !device->open(QIODevice::WriteOnly)) {
- throw MYMONEYEXCEPTION(i18n("Unable to open file '%1' for writing.", localFile));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unable to open file '%1' for writing.").arg(localFile));
}
pWriter->setProgressCallback(&KMyMoneyApp::progressCallback);
@@ -1140,7 +1140,7 @@
// Check for errors if possible, only possible for KGPGFile
QFileDevice *fileDevice = qobject_cast(device.get());
if (fileDevice && fileDevice->error() != QFileDevice::NoError) {
- throw MYMONEYEXCEPTION(i18n("Failure while writing to '%1'", localFile));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Failure while writing to '%1'").arg(localFile));
}
if (writeFile != localFile) {
@@ -1148,7 +1148,7 @@
// If a temporary file was created, it is made in a way that the name is definitely different. So no
// symlinks etc. have to be evaluated.
if (!QFile::remove(localFile) || !QFile::rename(writeFile, localFile))
- throw MYMONEYEXCEPTION(i18n("Failure while writing to '%1'", localFile));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Failure while writing to '%1'").arg(localFile));
}
QFile::setPermissions(localFile, m_fmode);
pWriter->setProgressCallback(0);
@@ -1412,7 +1412,7 @@
, acc.name()),
i18n("Account problem"));
- throw MYMONEYEXCEPTION("Fix LoanAccount0 not supported anymore");
+ throw MYMONEYEXCEPTION(QStringLiteral("Fix LoanAccount0 not supported anymore"));
}
}
@@ -2995,7 +2995,7 @@
}
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(0, i18n("Error"), i18n("Unable to import template(s): %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to import template(s)"), e.what());
}
}
delete dlg;
@@ -3438,7 +3438,7 @@
// We assume at least 2 splits in the transaction
MyMoneyTransaction t = newSchedule.transaction();
if (t.splitCount() < 2) {
- throw MYMONEYEXCEPTION("Transaction for schedule has less than 2 splits!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Transaction for schedule has less than 2 splits!"));
}
MyMoneyFileTransaction ft;
diff --git a/kmymoney/kmymoneyutils.cpp b/kmymoney/kmymoneyutils.cpp
--- a/kmymoney/kmymoneyutils.cpp
+++ b/kmymoney/kmymoneyutils.cpp
@@ -718,8 +718,7 @@
id = p.id();
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(nullptr, i18n("Unable to add payee"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(nullptr, i18n("Unable to add payee"), e.what());
doit = false;
}
}
@@ -766,8 +765,7 @@
id = ta.id();
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(nullptr, i18n("Unable to add tag"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(nullptr, i18n("Unable to add tag"), e.what());
}
}
}
diff --git a/kmymoney/main.cpp b/kmymoney/main.cpp
--- a/kmymoney/main.cpp
+++ b/kmymoney/main.cpp
@@ -229,9 +229,8 @@
try {
rc = runKMyMoney(app, std::move(splash), url, isNoFileOption);
} catch (const MyMoneyException &e) {
- KMessageBox::detailedError(0, i18n("Uncaught error. Please report the details to the developers"),
- i18n("%1 in file %2 line %3", e.what(), e.file(), e.line()));
- throw e;
+ KMessageBox::detailedError(0, i18n("Uncaught error. Please report the details to the developers"), e.what());
+ throw;
}
}
diff --git a/kmymoney/models/ledgermodel.cpp b/kmymoney/models/ledgermodel.cpp
--- a/kmymoney/models/ledgermodel.cpp
+++ b/kmymoney/models/ledgermodel.cpp
@@ -396,7 +396,7 @@
if(transactionId != d->m_lastTransactionStored.id()) {
try {
d->m_lastTransactionStored = MyMoneyFile::instance()->transaction(transactionId);
- } catch(MyMoneyException& e) {
+ } catch (const MyMoneyException &) {
d->m_lastTransactionStored = MyMoneyTransaction();
}
}
@@ -405,7 +405,7 @@
beginInsertRows(QModelIndex(), rowCount(), rowCount());
d->m_ledgerItems.append(new LedgerTransaction(d->m_lastTransactionStored, split));
endInsertRows();
- } catch(MyMoneyException& e) {
+ } catch (const MyMoneyException &) {
d->m_lastTransactionStored = MyMoneyTransaction();
}
}
diff --git a/kmymoney/models/ledgersplit.cpp b/kmymoney/models/ledgersplit.cpp
--- a/kmymoney/models/ledgersplit.cpp
+++ b/kmymoney/models/ledgersplit.cpp
@@ -58,7 +58,7 @@
if(!d->m_payeeId.isEmpty()) {
try {
d->m_payeeName = MyMoneyFile::instance()->payee(d->m_payeeId).name();
- } catch(MyMoneyException&) {
+ } catch (const MyMoneyException &) {
qDebug() << "payee" << d->m_payeeId << "not found.";
}
}
diff --git a/kmymoney/models/splitmodel.cpp b/kmymoney/models/splitmodel.cpp
--- a/kmymoney/models/splitmodel.cpp
+++ b/kmymoney/models/splitmodel.cpp
@@ -263,7 +263,7 @@
case (int)Role::PayeeName:
try {
rc = MyMoneyFile::instance()->payee(split.payeeId()).name();
- } catch(MyMoneyException&e) {
+ } catch (const MyMoneyException &e) {
}
break;
@@ -362,7 +362,7 @@
if(transactionId != d->m_transaction.id()) {
try {
d->m_transaction = MyMoneyFile::instance()->transaction(transactionId);
- } catch(MyMoneyException& e) {
+ } catch (const MyMoneyException &e) {
d->m_transaction = MyMoneyTransaction();
}
}
@@ -370,7 +370,7 @@
beginInsertRows(QModelIndex(), rowCount(), rowCount());
d->m_splits.append(d->m_transaction.splitById(splitId));
endInsertRows();
- } catch(MyMoneyException& e) {
+ } catch (const MyMoneyException &e) {
d->m_transaction = MyMoneyTransaction();
}
}
diff --git a/kmymoney/mymoney/CMakeLists.txt b/kmymoney/mymoney/CMakeLists.txt
--- a/kmymoney/mymoney/CMakeLists.txt
+++ b/kmymoney/mymoney/CMakeLists.txt
@@ -10,7 +10,7 @@
mymoneyobject.cpp
mymoneypayeeidentifiercontainer.cpp
mymoneysplit.cpp mymoneyinstitution.cpp
- mymoneyexception.cpp mymoneyinvesttransaction.cpp mymoneyutils.cpp
+ mymoneyinvesttransaction.cpp mymoneyutils.cpp
mymoneysecurity.cpp mymoneytransaction.cpp mymoneyschedule.cpp
mymoneypayee.cpp mymoneytracer.cpp
mymoneytag.cpp
diff --git a/kmymoney/mymoney/mymoneyaccount.cpp b/kmymoney/mymoney/mymoneyaccount.cpp
--- a/kmymoney/mymoney/mymoneyaccount.cpp
+++ b/kmymoney/mymoney/mymoneyaccount.cpp
@@ -64,7 +64,7 @@
MyMoneyKeyValueContainer(node.elementsByTagName(nodeNames[nnKeyValuePairs]).item(0).toElement())
{
if (nodeNames[nnAccount] != node.tagName())
- throw MYMONEYEXCEPTION("Node was not ACCOUNT");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not ACCOUNT"));
Q_D(MyMoneyAccount);
setName(node.attribute(d->getAttrName(Account::Attribute::Name)));
@@ -103,12 +103,10 @@
qWarning("XMLREADER: Account %s had invalid or no account type information.", qPrintable(name()));
}
- if (node.hasAttribute(d->getAttrName(Account::Attribute::OpeningBalance))) {
- if (!MyMoneyMoney(node.attribute(d->getAttrName(Account::Attribute::OpeningBalance))).isZero()) {
- QString msg = i18n("Account %1 contains an opening balance. Please use KMyMoney version 0.8 or later and earlier than version 0.9 to correct the problem.", d->m_name);
- throw MYMONEYEXCEPTION(msg);
- }
- }
+ if (node.hasAttribute(d->getAttrName(Account::Attribute::OpeningBalance)))
+ if (!MyMoneyMoney(node.attribute(d->getAttrName(Account::Attribute::OpeningBalance))).isZero())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Account %1 contains an opening balance. Please use KMyMoney version 0.8 or later and earlier than version 0.9 to correct the problem.").arg(d->m_name));
+
setDescription(node.attribute(d->getAttrName(Account::Attribute::Description)));
d->m_id = MyMoneyUtils::QStringEmpty(node.attribute(d->getAttrName(Account::Attribute::ID)));
diff --git a/kmymoney/mymoney/mymoneycostcenter.cpp b/kmymoney/mymoney/mymoneycostcenter.cpp
--- a/kmymoney/mymoney/mymoneycostcenter.cpp
+++ b/kmymoney/mymoney/mymoneycostcenter.cpp
@@ -55,7 +55,7 @@
MyMoneyObject(*new MyMoneyCostCenterPrivate, node)
{
if (nodeNames[nnCostCenter] != node.tagName())
- throw MYMONEYEXCEPTION("Node was not COSTCENTER");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not COSTCENTER"));
Q_D(MyMoneyCostCenter);
d->m_name = node.attribute(getAttrName(Attribute::Name));
diff --git a/kmymoney/mymoney/mymoneyexception.h b/kmymoney/mymoney/mymoneyexception.h
--- a/kmymoney/mymoney/mymoneyexception.h
+++ b/kmymoney/mymoney/mymoneyexception.h
@@ -2,14 +2,8 @@
mymoneyexception.h - description
-------------------
begin : Sun Apr 28 2002
- copyright : (C) 2000-2002 by Michael Edwardes
- email : mte@users.sourceforge.net
- Javier Campos Morales
- Felix Rodriguez
- John C
- Thomas Baumgart
- Kevin Tambascio
- (C) 2017 by Łukasz Wojniłowicz
+ copyright Thomas Baumgart
+ (C) 2017-2018 by Łukasz Wojniłowicz
***************************************************************************/
/***************************************************************************
@@ -24,110 +18,31 @@
#ifndef MYMONEYEXCEPTION_H
#define MYMONEYEXCEPTION_H
-#include "kmm_mymoney_export.h"
-
-// ----------------------------------------------------------------------------
-// QT Includes
-
-#include
-
-class QString;
-
/**
* @file
* @author Thomas Baumgart
+ * @author Łukasz Wojniłowicz
*/
/**
- * This class describes an exception that is thrown by the engine
- * in case of a failure.
- */
-
-class MyMoneyExceptionPrivate;
-class KMM_MYMONEY_EXPORT MyMoneyException
-{
-public:
-
- /**
- * @def MYMONEYEXCEPTION(text)
- * This is the preferred constructor to create a new exception
- * object. It automatically inserts the filename and the source
- * code line into the object upon creation.
- *
- * It is equivilant to MyMoneyException(text, __FILE__, __LINE__)
- */
-#define MYMONEYEXCEPTION(what) MyMoneyException(what, __FILE__, __LINE__)
-
- /**
- * The constructor to create a new MyMoneyException object.
- *
- * @param msg reference to QString containing the message
- * @param file reference to QString containing the name of the sourcefile where
- * the exception was thrown
- * @param line unsigned long containing the line number of the line where
- * the exception was thrown in the file.
- *
- * An easier way to use this constructor is to use the macro
- * MYMONEYEXCEPTION(text) instead. It automatically assigns the file
- * and line parameter to the correct values.
- */
- explicit MyMoneyException(const QString& msg,
- const QString& file,
- const unsigned long line);
+ * @def The MYMONEYEXCEPTION(exceptionMessage) define
+ * This is the preferred constructor to create a new exception
+ * object. It automatically inserts the filename and the source
+ * code line into the object upon creation.
+ */
- MyMoneyException(const MyMoneyException & other);
- MyMoneyException(MyMoneyException && other);
- MyMoneyException & operator=(MyMoneyException other);
- friend void swap(MyMoneyException& first, MyMoneyException& second);
+#define MYMONEYEXCEPTION(exceptionMessage) MyMoneyException(QString::fromLatin1("%1 %2:%3").arg(exceptionMessage, QString::fromLatin1(__FILE__), QString::number(__LINE__)))
- ~MyMoneyException();
+#include
- /**
- * This method is used to return the message that was passed
- * during the creation of the exception object.
- *
- * @return reference to QString containing the message
- */
- QString what() const;
-
- /**
- * This method is used to return the filename that was passed
- * during the creation of the exception object.
- *
- * @return reference to QString containing the filename
- */
- QString file() const;
-
- /**
- * This method is used to return the linenumber that was passed
- * during the creation of the exception object.
- *
- * @return long integer containing the line number
- */
- unsigned long line() const;
+class MyMoneyException
+{
+public:
+ explicit MyMoneyException(const QString &exceptionMessage) : m_exceptionMessage(exceptionMessage) {}
+ QString what() const { return m_exceptionMessage; }
private:
- // #define MYMONEYEXCEPTION(what) requires non-const d_ptr
- MyMoneyExceptionPrivate * d_ptr; // krazy:exclude=dpointer
- Q_DECLARE_PRIVATE(MyMoneyException)
- MyMoneyException();
+ QString m_exceptionMessage;
};
-inline void swap(MyMoneyException& first, MyMoneyException& second) // krazy:exclude=inline
-{
- using std::swap;
- swap(first.d_ptr, second.d_ptr);
-}
-
-inline MyMoneyException::MyMoneyException(MyMoneyException && other) : MyMoneyException() // krazy:exclude=inline
-{
- swap(*this, other);
-}
-
-inline MyMoneyException & MyMoneyException::operator=(MyMoneyException other) // krazy:exclude=inline
-{
- swap(*this, other);
- return *this;
-}
-
#endif
diff --git a/kmymoney/mymoney/mymoneyexception.cpp b/kmymoney/mymoney/mymoneyexception.cpp
deleted file mode 100644
--- a/kmymoney/mymoney/mymoneyexception.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/***************************************************************************
- mymoneyexception.cpp - description
- -------------------
- begin : Sun Apr 28 2002
- copyright : (C) 2000-2002 by Michael Edwardes
- email : mte@users.sourceforge.net
- Javier Campos Morales
- Felix Rodriguez
- John C
- Thomas Baumgart
- Kevin Tambascio
- (C) 2017 by Łukasz Wojniłowicz
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include "mymoneyexception.h"
-
-// ----------------------------------------------------------------------------
-// QT Includes
-
-#include
-
-// ----------------------------------------------------------------------------
-// KDE Includes
-
-// ----------------------------------------------------------------------------
-// Project Includes
-
-class MyMoneyExceptionPrivate
-{
-public:
- MyMoneyExceptionPrivate() :
- m_line(0)
- {
- }
-
- /**
- * This member variable holds the message
- */
- QString m_msg;
-
- /**
- * This member variable holds the filename
- */
- QString m_file;
-
- /**
- * This member variable holds the line number
- */
- unsigned long m_line;
-};
-
-MyMoneyException::MyMoneyException() :
- d_ptr(new MyMoneyExceptionPrivate)
-{
-}
-
-MyMoneyException::MyMoneyException(const QString& msg,
- const QString& file,
- const unsigned long line) :
- d_ptr(new MyMoneyExceptionPrivate)
-{
- Q_D(MyMoneyException);
- // qDebug("MyMoneyException(%s,%s,%ul)", qPrintable(msg), qPrintable(file), line);
- d->m_msg = msg;
- d->m_file = file;
- d->m_line = line;
-}
-
-MyMoneyException::MyMoneyException(const MyMoneyException& other) :
- d_ptr(new MyMoneyExceptionPrivate(*other.d_func()))
-{
-}
-
-MyMoneyException::~MyMoneyException()
-{
- Q_D(MyMoneyException);
- delete d;
-}
-
-QString MyMoneyException::what() const
-{
- Q_D(const MyMoneyException);
- return d->m_msg;
-}
-
-QString MyMoneyException::file() const
-{
- Q_D(const MyMoneyException);
- return d->m_file;
-}
-
-unsigned long MyMoneyException::line() const
-{
- Q_D(const MyMoneyException);
- return d->m_line;
-}
diff --git a/kmymoney/mymoney/mymoneyfile.cpp b/kmymoney/mymoney/mymoneyfile.cpp
--- a/kmymoney/mymoney/mymoneyfile.cpp
+++ b/kmymoney/mymoney/mymoneyfile.cpp
@@ -206,7 +206,7 @@
*/
inline void checkStorage() const {
if (m_storage == 0)
- throw MYMONEYEXCEPTION("No storage object attached to MyMoneyFile");
+ throw MYMONEYEXCEPTION(QStringLiteral("No storage object attached to MyMoneyFile"));
}
/**
@@ -216,9 +216,8 @@
*/
void checkTransaction(const char* txt) const {
checkStorage();
- if (!m_inTransaction) {
- throw MYMONEYEXCEPTION(QString("No transaction started for %1").arg(txt));
- }
+ if (!m_inTransaction)
+ throw MYMONEYEXCEPTION(QString::fromLatin1("No transaction started for %1").arg(QString::fromLatin1(txt)));
}
void priceChanged(const MyMoneyFile& file, const MyMoneyPrice price) {
@@ -328,10 +327,10 @@
void MyMoneyFile::attachStorage(MyMoneyStorageMgr* const storage)
{
if (d->m_storage != 0)
- throw MYMONEYEXCEPTION("Storage already attached");
+ throw MYMONEYEXCEPTION(QStringLiteral("Storage already attached"));
if (storage == 0)
- throw MYMONEYEXCEPTION("Storage must not be 0");
+ throw MYMONEYEXCEPTION(QStringLiteral("Storage must not be 0"));
d->m_storage = storage;
@@ -369,7 +368,7 @@
{
d->checkStorage();
if (d->m_inTransaction) {
- throw MYMONEYEXCEPTION("Already started a transaction!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Already started a transaction!"));
}
d->m_storage->startTransaction();
@@ -463,7 +462,7 @@
if (institution.name().length() == 0
|| institution.id().length() != 0)
- throw MYMONEYEXCEPTION("Not a new institution");
+ throw MYMONEYEXCEPTION(QStringLiteral("Not a new institution"));
d->checkTransaction(Q_FUNC_INFO);
@@ -493,9 +492,9 @@
// account does not exist
auto acc = MyMoneyFile::account(split.accountId());
if (acc.id().isEmpty())
- throw MYMONEYEXCEPTION("Cannot store split with no account assigned");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot store split with no account assigned"));
if (isStandardAccount(split.accountId()))
- throw MYMONEYEXCEPTION("Cannot store split referencing standard account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot store split referencing standard account"));
if (acc.isLoan() && (split.action() == MyMoneySplit::actionName(eMyMoney::Split::Action::Transfer)))
loanAccountAffected = true;
}
@@ -562,12 +561,12 @@
// now check that it is the same
if (!(account == _account))
- throw MYMONEYEXCEPTION("Unable to modify the standard account groups");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to modify the standard account groups"));
}
if (account.accountType() != acc.accountType() &&
!account.isLiquidAsset() && !acc.isLiquidAsset())
- throw MYMONEYEXCEPTION("Unable to change account type");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to change account type"));
// if the account was moved to another institution, we notify
// the old one as well as the new one and the structure change
@@ -597,17 +596,17 @@
// check that it's not one of the standard account groups
if (isStandardAccount(acc.id()))
- throw MYMONEYEXCEPTION("Unable to reparent the standard account groups");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to reparent the standard account groups"));
if (acc.accountGroup() == parent.accountGroup()
|| (acc.accountType() == Account::Type::Income && parent.accountType() == Account::Type::Expense)
|| (acc.accountType() == Account::Type::Expense && parent.accountType() == Account::Type::Income)) {
if (acc.isInvest() && parent.accountType() != Account::Type::Investment)
- throw MYMONEYEXCEPTION("Unable to reparent Stock to non-investment account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to reparent Stock to non-investment account"));
if (parent.accountType() == Account::Type::Investment && !acc.isInvest())
- throw MYMONEYEXCEPTION("Unable to reparent non-stock to investment account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to reparent non-stock to investment account"));
// keep a notification of the current parent
MyMoneyAccount curParent = account(acc.parentAccountId());
@@ -619,7 +618,7 @@
d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc);
} else
- throw MYMONEYEXCEPTION("Unable to reparent to different account type");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to reparent to different account type"));
}
MyMoneyInstitution MyMoneyFile::institution(const QString& id) const
@@ -652,7 +651,7 @@
{
try {
return d->m_storage->accountByName(name);
- } catch(const MyMoneyException&) {
+ } catch (const MyMoneyException &) {
}
return MyMoneyAccount();
}
@@ -672,7 +671,7 @@
for (const auto& split : splits) {
auto acc = account(split.accountId());
if (acc.isClosed())
- throw MYMONEYEXCEPTION(i18n("Cannot remove transaction that references a closed account."));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot remove transaction that references a closed account."));
d->addCacheNotification(split.accountId(), tr.postDate());
//FIXME-ALEX Do I need to add d->addCacheNotification(split.tagList()); ??
}
@@ -733,10 +732,10 @@
// check that it's not one of the standard account groups
if (isStandardAccount(account.id()))
- throw MYMONEYEXCEPTION("Unable to remove the standard account groups");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to remove the standard account groups"));
if (hasActiveSplits(account.id())) {
- throw MYMONEYEXCEPTION("Unable to remove account with active splits");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to remove account with active splits"));
}
// collect all sub-ordinate accounts for notification
@@ -764,14 +763,14 @@
void MyMoneyFile::removeAccountList(const QStringList& account_list, unsigned int level)
{
if (level > 100)
- throw MYMONEYEXCEPTION("Too deep recursion in [MyMoneyFile::removeAccountList]!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Too deep recursion in [MyMoneyFile::removeAccountList]!"));
d->checkTransaction(Q_FUNC_INFO);
// upon entry, we check that we could proceed with the operation
if (!level) {
if (!hasOnlyUnusedAccounts(account_list, 0)) {
- throw MYMONEYEXCEPTION("One or more accounts cannot be removed");
+ throw MYMONEYEXCEPTION(QStringLiteral("One or more accounts cannot be removed"));
}
}
@@ -798,7 +797,7 @@
bool MyMoneyFile::hasOnlyUnusedAccounts(const QStringList& account_list, unsigned int level)
{
if (level > 100)
- throw MYMONEYEXCEPTION("Too deep recursion in [MyMoneyFile::hasOnlyUnusedAccounts]!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Too deep recursion in [MyMoneyFile::hasOnlyUnusedAccounts]!"));
// process all accounts in the list and test if they have transactions assigned
for (const auto& sAccount : account_list) {
if (transactionCount(sAccount) != 0)
@@ -907,7 +906,7 @@
ft.commit();
} catch (const MyMoneyException &e) {
qWarning("Unable to create account: %s", qPrintable(e.what()));
- throw MYMONEYEXCEPTION(e.what());
+ throw;
}
}
@@ -923,19 +922,19 @@
// it's own ID is not set and it does not have a pointer to (MyMoneyFile)
if (account.name().length() == 0)
- throw MYMONEYEXCEPTION("Account has no name");
+ throw MYMONEYEXCEPTION(QStringLiteral("Account has no name"));
if (account.id().length() != 0)
- throw MYMONEYEXCEPTION("New account must have no id");
+ throw MYMONEYEXCEPTION(QStringLiteral("New account must have no id"));
if (account.accountList().count() != 0)
- throw MYMONEYEXCEPTION("New account must have no sub-accounts");
+ throw MYMONEYEXCEPTION(QStringLiteral("New account must have no sub-accounts"));
if (!account.parentAccountId().isEmpty())
- throw MYMONEYEXCEPTION("New account must have no parent-id");
+ throw MYMONEYEXCEPTION(QStringLiteral("New account must have no parent-id"));
if (account.accountType() == Account::Type::Unknown)
- throw MYMONEYEXCEPTION("Account has invalid type");
+ throw MYMONEYEXCEPTION(QStringLiteral("Account has invalid type"));
// make sure, that the parent account exists
// if not, an exception is thrown. If it exists,
@@ -968,13 +967,13 @@
// that the parent for a stock account must be an investment. Also,
// an investment cannot have another investment account as it's parent
if (parent.isInvest())
- throw MYMONEYEXCEPTION("Stock account cannot be parent account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Stock account cannot be parent account"));
if (account.isInvest() && parent.accountType() != Account::Type::Investment)
- throw MYMONEYEXCEPTION("Stock account must have investment account as parent ");
+ throw MYMONEYEXCEPTION(QStringLiteral("Stock account must have investment account as parent "));
if (!account.isInvest() && parent.accountType() == Account::Type::Investment)
- throw MYMONEYEXCEPTION("Investment account can only have stock accounts as children");
+ throw MYMONEYEXCEPTION(QStringLiteral("Investment account can only have stock accounts as children"));
// if an institution is set, verify that it exists
if (account.institutionId().length() != 0) {
@@ -1091,7 +1090,7 @@
MyMoneyAccount MyMoneyFile::openingBalanceAccount(const MyMoneySecurity& security)
{
if (!security.isCurrency())
- throw MYMONEYEXCEPTION("Opening balance for non currencies not supported");
+ throw MYMONEYEXCEPTION(QStringLiteral("Opening balance for non currencies not supported"));
try {
return openingBalanceAccount_internal(security);
@@ -1118,7 +1117,7 @@
MyMoneyAccount MyMoneyFile::openingBalanceAccount_internal(const MyMoneySecurity& security) const
{
if (!security.isCurrency())
- throw MYMONEYEXCEPTION("Opening balance for non currencies not supported");
+ throw MYMONEYEXCEPTION(QStringLiteral("Opening balance for non currencies not supported"));
MyMoneyAccount acc;
QList accounts;
@@ -1144,9 +1143,8 @@
}
}
- if (acc.id().isEmpty()) {
- throw MYMONEYEXCEPTION(QString("No opening balance account for %1").arg(security.tradingSymbol()));
- }
+ if (acc.id().isEmpty())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("No opening balance account for %1").arg(security.tradingSymbol()));
return acc;
}
@@ -1205,9 +1203,9 @@
// first perform all the checks
if (!transaction.id().isEmpty())
- throw MYMONEYEXCEPTION("Unable to add transaction with id set");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to add transaction with id set"));
if (!transaction.postDate().isValid())
- throw MYMONEYEXCEPTION("Unable to add transaction with invalid postdate");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to add transaction with invalid postdate"));
// now check the splits
auto loanAccountAffected = false;
@@ -1217,11 +1215,11 @@
// account does not exist or is one of the standard accounts
auto acc = MyMoneyFile::account(split.accountId());
if (acc.id().isEmpty())
- throw MYMONEYEXCEPTION("Cannot add split with no account assigned");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot add split with no account assigned"));
if (acc.isLoan())
loanAccountAffected = true;
if (isStandardAccount(split.accountId()))
- throw MYMONEYEXCEPTION("Cannot add split referencing standard account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot add split referencing standard account"));
}
// change transfer splits between asset/liability and loan accounts
@@ -1577,7 +1575,7 @@
qWarning("Missing price info for conversion from %s to %s", qPrintable(from.name()), qPrintable(to.name()));
} catch (const MyMoneyException &e) {
- qWarning("Missing security caught in MyMoneyFile::warningMissingRate(): %s(%ld) %s", qPrintable(e.file()), e.line(), qPrintable(e.what()));
+ qWarning("Missing security caught in MyMoneyFile::warningMissingRate(). %s", qPrintable(e.what()));
}
}
@@ -1718,9 +1716,9 @@
// account does not exist or is one of the standard accounts
const auto acc = account(split.accountId());
if (acc.id().isEmpty())
- throw MYMONEYEXCEPTION("Cannot add split with no account assigned");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot add split with no account assigned"));
if (isStandardAccount(split.accountId()))
- throw MYMONEYEXCEPTION("Cannot add split referencing standard account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot add split referencing standard account"));
}
d->m_storage->addSchedule(sched);
@@ -1736,9 +1734,9 @@
// account does not exist or is one of the standard accounts
auto acc = MyMoneyFile::account(split.accountId());
if (acc.id().isEmpty())
- throw MYMONEYEXCEPTION("Cannot store split with no account assigned");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot store split with no account assigned"));
if (isStandardAccount(split.accountId()))
- throw MYMONEYEXCEPTION("Cannot store split referencing standard account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot store split referencing standard account"));
}
d->m_storage->modifySchedule(sched);
@@ -1940,7 +1938,7 @@
try {
child = account(accountID);
if (child.parentAccountId() != (*it_a).id()) {
- throw MYMONEYEXCEPTION("Child account has a different parent");
+ throw MYMONEYEXCEPTION(QStringLiteral("Child account has a different parent"));
}
} catch (const MyMoneyException &) {
problemCount++;
@@ -2446,7 +2444,7 @@
QString categoryText;
if (base.id() != expense().id() && base.id() != income().id())
- throw MYMONEYEXCEPTION("Invalid base category");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid base category"));
QStringList subAccounts = name.split(AccountSeparator);
QStringList::Iterator it;
@@ -2609,7 +2607,7 @@
d->checkTransaction(Q_FUNC_INFO);
if (currency.id() == d->m_baseCurrency.id())
- throw MYMONEYEXCEPTION("Cannot delete base currency.");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot delete base currency."));
// FIXME check that security is not referenced by other object
@@ -2629,7 +2627,7 @@
return currency;
- } catch(const MyMoneyException&) {
+ } catch (const MyMoneyException &) {
const auto security = d->m_storage->security(id);
if (security.id().isEmpty()) {
throw MYMONEYEXCEPTION(QString::fromLatin1("Security '%1' not found.").arg(id));
@@ -3435,7 +3433,7 @@
{
try {
rollback();
- } catch (const MyMoneyException & e) {
+ } catch (const MyMoneyException &e) {
qDebug() << e.what();
}
Q_D(MyMoneyFileTransaction);
diff --git a/kmymoney/mymoney/mymoneyfinancialcalculator.cpp b/kmymoney/mymoney/mymoneyfinancialcalculator.cpp
--- a/kmymoney/mymoney/mymoneyfinancialcalculator.cpp
+++ b/kmymoney/mymoney/mymoneyfinancialcalculator.cpp
@@ -169,7 +169,7 @@
const unsigned short mask = PV_SET | IR_SET | PMT_SET | FV_SET;
if ((d->m_mask & mask) != mask)
- throw MYMONEYEXCEPTION("Not all parameters set for calculation of numPayments");
+ throw MYMONEYEXCEPTION(QStringLiteral("Not all parameters set for calculation of numPayments"));
double eint = d->eff_int();
@@ -194,7 +194,7 @@
const unsigned short mask = PV_SET | IR_SET | NPP_SET | FV_SET;
if ((d->m_mask & mask) != mask)
- throw MYMONEYEXCEPTION("Not all parameters set for calculation of payment");
+ throw MYMONEYEXCEPTION(QStringLiteral("Not all parameters set for calculation of payment"));
double eint = d->eff_int();
@@ -218,7 +218,7 @@
const unsigned short mask = PMT_SET | IR_SET | NPP_SET | FV_SET;
if ((d->m_mask & mask) != mask)
- throw MYMONEYEXCEPTION("Not all parameters set for calculation of payment");
+ throw MYMONEYEXCEPTION(QStringLiteral("Not all parameters set for calculation of payment"));
double eint = d->eff_int();
@@ -243,7 +243,7 @@
const unsigned short mask = PMT_SET | IR_SET | NPP_SET | PV_SET;
if ((d->m_mask & mask) != mask)
- throw MYMONEYEXCEPTION("Not all parameters set for calculation of payment");
+ throw MYMONEYEXCEPTION(QStringLiteral("Not all parameters set for calculation of payment"));
double eint = d->eff_int();
diff --git a/kmymoney/mymoney/mymoneyfinancialcalculator_p.h b/kmymoney/mymoney/mymoneyfinancialcalculator_p.h
--- a/kmymoney/mymoney/mymoneyfinancialcalculator_p.h
+++ b/kmymoney/mymoney/mymoneyfinancialcalculator_p.h
@@ -84,7 +84,7 @@
double _Bx(const double eint) const
{
if (eint == 0.0)
- throw MYMONEYEXCEPTION("Zero interest");
+ throw MYMONEYEXCEPTION(QStringLiteral("Zero interest"));
if (m_bep == false)
return static_cast(1.0) / eint;
diff --git a/kmymoney/mymoney/mymoneyforecast.cpp b/kmymoney/mymoney/mymoneyforecast.cpp
--- a/kmymoney/mymoney/mymoneyforecast.cpp
+++ b/kmymoney/mymoney/mymoneyforecast.cpp
@@ -1030,7 +1030,7 @@
if (fAccCycle < 1
|| fCycles < 1
|| fDays < 1) {
- throw MYMONEYEXCEPTION("Illegal settings when calling doForecast. Settings must be higher than 0");
+ throw MYMONEYEXCEPTION(QStringLiteral("Illegal settings when calling doForecast. Settings must be higher than 0"));
}
//initialize global variables
@@ -1106,7 +1106,7 @@
//validate arguments
if (trendDays < 1) {
- throw MYMONEYEXCEPTION("Illegal arguments when calling calculateAccountTrend. trendDays must be higher than 0");
+ throw MYMONEYEXCEPTION(QStringLiteral("Illegal arguments when calling calculateAccountTrend. trendDays must be higher than 0"));
}
//If it is a new account, we don't take into account the first day
@@ -1328,7 +1328,7 @@
if (historyStart > historyEnd ||
budgetStart > budgetEnd ||
budgetStart <= historyEnd) {
- throw MYMONEYEXCEPTION("Illegal parameters when trying to create budget");
+ throw MYMONEYEXCEPTION(QStringLiteral("Illegal parameters when trying to create budget"));
}
//get forecast method
diff --git a/kmymoney/mymoney/mymoneyinstitution.cpp b/kmymoney/mymoney/mymoneyinstitution.cpp
--- a/kmymoney/mymoney/mymoneyinstitution.cpp
+++ b/kmymoney/mymoney/mymoneyinstitution.cpp
@@ -73,7 +73,7 @@
MyMoneyKeyValueContainer(node.elementsByTagName(nodeNames[nnKeyValuePairs]).item(0).toElement())
{
if (nodeNames[nnInstitution] != node.tagName())
- throw MYMONEYEXCEPTION("Node was not INSTITUTION");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not INSTITUTION"));
Q_D(MyMoneyInstitution);
d->m_sortcode = node.attribute(d->getAttrName(Institution::Attribute::SortCode));
@@ -81,10 +81,8 @@
d->m_manager = node.attribute(d->getAttrName(Institution::Attribute::Manager));
QDomNodeList nodeList = node.elementsByTagName(d->getElName(Institution::Element::Address));
- if (nodeList.count() == 0) {
- QString msg = QString("No ADDRESS in institution %1").arg(d->m_name);
- throw MYMONEYEXCEPTION(msg);
- }
+ if (nodeList.isEmpty())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("No ADDRESS in institution %1").arg(d->m_name));
QDomElement addrNode = nodeList.item(0).toElement();
d->m_street = addrNode.attribute(d->getAttrName(Institution::Attribute::Street));
diff --git a/kmymoney/mymoney/mymoneykeyvaluecontainer.cpp b/kmymoney/mymoney/mymoneykeyvaluecontainer.cpp
--- a/kmymoney/mymoney/mymoneykeyvaluecontainer.cpp
+++ b/kmymoney/mymoney/mymoneykeyvaluecontainer.cpp
@@ -49,7 +49,7 @@
Q_D(MyMoneyKeyValueContainer);
if (!node.isNull()) {
if (nodeNames[nnKeyValuePairs] != node.tagName())
- throw MYMONEYEXCEPTION("Node was not KEYVALUEPAIRS");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not KEYVALUEPAIRS"));
d->m_kvp.clear();
diff --git a/kmymoney/mymoney/mymoneymoney.cpp b/kmymoney/mymoney/mymoneymoney.cpp
--- a/kmymoney/mymoney/mymoneymoney.cpp
+++ b/kmymoney/mymoney/mymoneymoney.cpp
@@ -145,7 +145,7 @@
MyMoneyMoney::MyMoneyMoney(signed64 Amount, const signed64 denom)
{
if (!denom)
- throw MYMONEYEXCEPTION("Denominator 0 not allowed!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Denominator 0 not allowed!"));
*this = AlkValue(QString::fromLatin1("%1/%2").arg(Amount).arg(denom), eMyMoney::Money::_decimalSeparator);
}
@@ -162,7 +162,7 @@
MyMoneyMoney::MyMoneyMoney(const int iAmount, const signed64 denom)
{
if (!denom)
- throw MYMONEYEXCEPTION("Denominator 0 not allowed!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Denominator 0 not allowed!"));
*this = AlkValue(iAmount, denom);
}
@@ -178,7 +178,7 @@
MyMoneyMoney::MyMoneyMoney(const long int iAmount, const signed64 denom)
{
if (!denom)
- throw MYMONEYEXCEPTION("Denominator 0 not allowed!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Denominator 0 not allowed!"));
*this = AlkValue(QString::fromLatin1("%1/%2").arg(iAmount).arg(denom), eMyMoney::Money::_decimalSeparator);
}
diff --git a/kmymoney/mymoney/mymoneyobject.cpp b/kmymoney/mymoney/mymoneyobject.cpp
--- a/kmymoney/mymoney/mymoneyobject.cpp
+++ b/kmymoney/mymoney/mymoneyobject.cpp
@@ -47,7 +47,7 @@
Q_D(MyMoneyObject);
d->m_id = node.attribute(QStringLiteral("id"));
if (d->m_id.length() == 0 && forceId)
- throw MYMONEYEXCEPTION("Node has no ID");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node has no ID"));
}
MyMoneyObject::~MyMoneyObject()
diff --git a/kmymoney/mymoney/mymoneypayee.cpp b/kmymoney/mymoney/mymoneypayee.cpp
--- a/kmymoney/mymoney/mymoneypayee.cpp
+++ b/kmymoney/mymoney/mymoneypayee.cpp
@@ -68,7 +68,7 @@
MyMoneyObject(*new MyMoneyPayeePrivate, node)
{
if (nodeNames[nnPayee] != node.tagName()) {
- throw MYMONEYEXCEPTION("Node was not PAYEE");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not PAYEE"));
}
Q_D(MyMoneyPayee);
@@ -93,10 +93,8 @@
// Load Address
QDomNodeList nodeList = node.elementsByTagName(d->getElName(Payee::Element::Address));
- if (nodeList.count() == 0) {
- QString msg = QString("No ADDRESS in payee %1").arg(d->m_name);
- throw MYMONEYEXCEPTION(msg);
- }
+ if (nodeList.isEmpty())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("No ADDRESS in payee %1").arg(d->m_name));
QDomElement addrNode = nodeList.item(0).toElement();
d->m_address = addrNode.attribute(d->getAttrName(Payee::Attribute::Street));
diff --git a/kmymoney/mymoney/mymoneyprice.cpp b/kmymoney/mymoney/mymoneyprice.cpp
--- a/kmymoney/mymoney/mymoneyprice.cpp
+++ b/kmymoney/mymoney/mymoneyprice.cpp
@@ -65,7 +65,7 @@
d_ptr(new MyMoneyPricePrivate)
{
if ("PRICE" != node.tagName())
- throw MYMONEYEXCEPTION("Node was not PRICE");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not PRICE"));
Q_D(MyMoneyPrice);
d->m_fromSecurity = from;
@@ -122,8 +122,7 @@
if (id == d->m_fromSecurity)
return d->m_invRate;
- QString msg = QString("Unknown security id %1 for price info %2/%3.").arg(id).arg(d->m_fromSecurity).arg(d->m_toSecurity);
- throw MYMONEYEXCEPTION(msg);
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown security id %1 for price info %2/%3.").arg(id, d->m_fromSecurity, d->m_toSecurity));
}
QDate MyMoneyPrice::date() const
diff --git a/kmymoney/mymoney/mymoneyreport.cpp b/kmymoney/mymoney/mymoneyreport.cpp
--- a/kmymoney/mymoney/mymoneyreport.cpp
+++ b/kmymoney/mymoney/mymoneyreport.cpp
@@ -182,7 +182,7 @@
//throw exception if the type is inconsistent
if ((rt > static_cast(sizeof(kTypeArray) / sizeof(kTypeArray[0])))
|| (d->m_reportType == eNoReport))
- throw MYMONEYEXCEPTION("Invalid report type");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid report type"));
//add the corresponding account groups
if (rt == MyMoneyReport::eAssetLiability) {
diff --git a/kmymoney/mymoney/mymoneyschedule.cpp b/kmymoney/mymoney/mymoneyschedule.cpp
--- a/kmymoney/mymoney/mymoneyschedule.cpp
+++ b/kmymoney/mymoney/mymoneyschedule.cpp
@@ -80,7 +80,7 @@
MyMoneyObject(*new MyMoneySchedulePrivate, node)
{
if (nodeNames[nnScheduleTX] != node.tagName())
- throw MYMONEYEXCEPTION("Node was not SCHEDULED_TX");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not SCHEDULED_TX"));
Q_D(MyMoneySchedule);
d->m_name = node.attribute(d->getAttrName(Schedule::Attribute::Name));
@@ -102,7 +102,7 @@
// read in the associated transaction
QDomNodeList nodeList = node.elementsByTagName(nodeNames[nnTransaction]);
if (nodeList.count() == 0)
- throw MYMONEYEXCEPTION("SCHEDULED_TX has no TRANSACTION node");
+ throw MYMONEYEXCEPTION(QStringLiteral("SCHEDULED_TX has no TRANSACTION node"));
setTransaction(MyMoneyTransaction(nodeList.item(0).toElement(), false), true);
@@ -447,37 +447,37 @@
*/
Q_D(const MyMoneySchedule);
if (id_check && !d->m_id.isEmpty())
- throw MYMONEYEXCEPTION("ID for schedule not empty when required");
+ throw MYMONEYEXCEPTION(QStringLiteral("ID for schedule not empty when required"));
if (d->m_occurrence == Schedule::Occurrence::Any)
- throw MYMONEYEXCEPTION("Invalid occurrence type for schedule");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid occurrence type for schedule"));
if (d->m_type == Schedule::Type::Any)
- throw MYMONEYEXCEPTION("Invalid type for schedule");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid type for schedule"));
if (!nextDueDate().isValid())
- throw MYMONEYEXCEPTION("Invalid next due date for schedule");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid next due date for schedule"));
if (d->m_paymentType == Schedule::PaymentType::Any)
- throw MYMONEYEXCEPTION("Invalid payment type for schedule");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid payment type for schedule"));
if (d->m_transaction.splitCount() == 0)
- throw MYMONEYEXCEPTION("Scheduled transaction does not contain splits");
+ throw MYMONEYEXCEPTION(QStringLiteral("Scheduled transaction does not contain splits"));
// Check the payment types
switch (d->m_type) {
case Schedule::Type::Bill:
if (d->m_paymentType == Schedule::PaymentType::DirectDeposit || d->m_paymentType == Schedule::PaymentType::ManualDeposit)
- throw MYMONEYEXCEPTION("Invalid payment type for bills");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid payment type for bills"));
break;
case Schedule::Type::Deposit:
if (d->m_paymentType == Schedule::PaymentType::DirectDebit || d->m_paymentType == Schedule::PaymentType::WriteChecque)
- throw MYMONEYEXCEPTION("Invalid payment type for deposits");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid payment type for deposits"));
break;
case Schedule::Type::Any:
- throw MYMONEYEXCEPTION("Invalid type ANY");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid type ANY"));
break;
case Schedule::Type::Transfer:
diff --git a/kmymoney/mymoney/mymoneysecurity.cpp b/kmymoney/mymoney/mymoneysecurity.cpp
--- a/kmymoney/mymoney/mymoneysecurity.cpp
+++ b/kmymoney/mymoney/mymoneysecurity.cpp
@@ -85,7 +85,7 @@
if ((nodeNames[nnSecurity] != tag)
&& (nodeNames[nnEquity] != tag)
&& (nodeNames[nnCurrency] != tag))
- throw MYMONEYEXCEPTION("Node was not SECURITY or CURRENCY");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not SECURITY or CURRENCY"));
}
Q_D(MyMoneySecurity);
diff --git a/kmymoney/mymoney/mymoneysplit.cpp b/kmymoney/mymoney/mymoneysplit.cpp
--- a/kmymoney/mymoney/mymoneysplit.cpp
+++ b/kmymoney/mymoney/mymoneysplit.cpp
@@ -53,7 +53,7 @@
{
Q_D(MyMoneySplit);
if (d->getElName(Split::Element::Split) != node.tagName())
- throw MYMONEYEXCEPTION("Node was not SPLIT");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not SPLIT"));
clearId();
diff --git a/kmymoney/mymoney/mymoneytag.cpp b/kmymoney/mymoney/mymoneytag.cpp
--- a/kmymoney/mymoney/mymoneytag.cpp
+++ b/kmymoney/mymoney/mymoneytag.cpp
@@ -59,7 +59,7 @@
MyMoneyObject(*new MyMoneyTagPrivate, node)
{
if (nodeNames[nnTag] != node.tagName()) {
- throw MYMONEYEXCEPTION("Node was not TAG");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not TAG"));
}
Q_D(MyMoneyTag);
d->m_name = node.attribute(d->getAttrName(Tag::Attribute::Name));
diff --git a/kmymoney/mymoney/mymoneytransaction.cpp b/kmymoney/mymoney/mymoneytransaction.cpp
--- a/kmymoney/mymoney/mymoneytransaction.cpp
+++ b/kmymoney/mymoney/mymoneytransaction.cpp
@@ -51,7 +51,7 @@
{
Q_D(MyMoneyTransaction);
if (nodeNames[nnTransaction] != node.tagName())
- throw MYMONEYEXCEPTION("Node was not TRANSACTION");
+ throw MYMONEYEXCEPTION(QStringLiteral("Node was not TRANSACTION"));
d->m_nextSplitID = 1;
@@ -241,10 +241,10 @@
void MyMoneyTransaction::addSplit(MyMoneySplit &split)
{
if (!split.id().isEmpty())
- throw MYMONEYEXCEPTION("Cannot add split with assigned id (" + split.id() + ')');
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot add split with assigned id '%1'").arg(split.id()));
if (split.accountId().isEmpty())
- throw MYMONEYEXCEPTION("Cannot add split that does not contain an account reference");
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot add split that does not contain an account reference"));
Q_D(MyMoneyTransaction);
MyMoneySplit newSplit(d->nextSplitID(), split);
@@ -258,7 +258,7 @@
// This is the other version which allows having more splits referencing
// the same account.
if (split.accountId().isEmpty())
- throw MYMONEYEXCEPTION("Cannot modify split that does not contain an account reference");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot modify split that does not contain an account reference"));
Q_D(MyMoneyTransaction);
for (auto& it_split : d->m_splits) {
@@ -267,7 +267,7 @@
return;
}
}
- throw MYMONEYEXCEPTION(QString("Invalid split id '%1'").arg(split.id()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid split id '%1'").arg(split.id()));
}
void MyMoneyTransaction::removeSplit(const MyMoneySplit& split)
@@ -280,7 +280,7 @@
}
}
- throw MYMONEYEXCEPTION(QString("Invalid split id '%1'").arg(split.id()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid split id '%1'").arg(split.id()));
}
void MyMoneyTransaction::removeSplits()
@@ -297,7 +297,7 @@
if (split.payeeId() == payeeId)
return split;
}
- throw MYMONEYEXCEPTION(QString("Split not found for payee '%1'").arg(QString(payeeId)));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Split not found for payee '%1'").arg(QString(payeeId)));
}
MyMoneySplit MyMoneyTransaction::splitByAccount(const QString& accountId, const bool match) const
@@ -308,7 +308,7 @@
(match == false && split.accountId() != accountId))
return split;
}
- throw MYMONEYEXCEPTION(QString("Split not found for account %1%2").arg(match ? "" : "!").arg(QString(accountId)));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Split not found for account %1%2").arg(match ? "" : "!").arg(QString(accountId)));
}
MyMoneySplit MyMoneyTransaction::splitByAccount(const QStringList& accountIds, const bool match) const
@@ -319,7 +319,7 @@
(match == false && !accountIds.contains(split.accountId())))
return split;
}
- throw MYMONEYEXCEPTION(QString("Split not found for account %1%1...%2").arg(match ? "" : "!").arg(accountIds.front(), accountIds.back()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Split not found for account %1%1...%2").arg(match ? "" : "!").arg(accountIds.front(), accountIds.back()));
}
MyMoneySplit MyMoneyTransaction::splitById(const QString& splitId) const
@@ -329,7 +329,7 @@
if (split.id() == splitId)
return split;
}
- throw MYMONEYEXCEPTION(QString("Split not found for id '%1'").arg(QString(splitId)));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Split not found for id '%1'").arg(QString(splitId)));
}
QString MyMoneyTransaction::firstSplitID()
diff --git a/kmymoney/mymoney/onlinejob.h b/kmymoney/mymoney/onlinejob.h
--- a/kmymoney/mymoney/onlinejob.h
+++ b/kmymoney/mymoney/onlinejob.h
@@ -20,6 +20,11 @@
#ifndef ONLINEJOB_H
#define ONLINEJOB_H
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+#define BADTASKEXCEPTION(what) badTaskCast("Casted onlineTask with wrong type. " __FILE__ ":" TOSTRING(__LINE__))
+#define EMPTYTASKEXCEPTION(what) emptyTask("Requested onlineTask of onlineJob without any task. " __FILE__ ":" TOSTRING(__LINE__))
+
#include
#include
#include "mymoneyobject.h"
@@ -288,21 +293,19 @@
*
* This is inspired by std::bad_cast
*/
- class badTaskCast : public MyMoneyException
+ class badTaskCast : public std::runtime_error
{
public:
- explicit badTaskCast(const QString& file = QString(), const long unsigned int& line = 0)
- : MyMoneyException("Casted onlineTask with wrong type", file, line) {}
+ explicit badTaskCast(const char *msg) : std::runtime_error(msg) {}
};
/**
* @brief Thrown if a task of an invalid onlineJob is requested
*/
- class emptyTask : public MyMoneyException
+ class emptyTask : public std::runtime_error
{
public:
- explicit emptyTask(const QString& file = QString(), const long unsigned int& line = 0)
- : MyMoneyException("Requested onlineTask of onlineJob without any task", file, line) {}
+ explicit emptyTask(const char *msg) : std::runtime_error(msg) {}
};
/** @brief onlineTask attatched to this job */
@@ -337,7 +340,8 @@
{
T* ret = dynamic_cast(m_task);
if (ret == 0)
- throw badTaskCast(__FILE__, __LINE__);
+ throw EMPTYTASKEXCEPTION();
+// throw badTaskCast(__FILE__, __LINE__);
return ret;
}
@@ -346,7 +350,8 @@
{
const T* ret = dynamic_cast(m_task);
if (ret == 0)
- throw badTaskCast(__FILE__, __LINE__);
+ throw BADTASKEXCEPTION();
+// throw badTaskCast(__FILE__, __LINE__);
return ret;
}
diff --git a/kmymoney/mymoney/onlinejob.cpp b/kmymoney/mymoney/onlinejob.cpp
--- a/kmymoney/mymoney/onlinejob.cpp
+++ b/kmymoney/mymoney/onlinejob.cpp
@@ -135,14 +135,14 @@
onlineTask* onlineJob::task()
{
if (m_task == 0)
- throw emptyTask(__FILE__, __LINE__);
+ throw EMPTYTASKEXCEPTION();
return m_task;
}
const onlineTask* onlineJob::task() const
{
if (m_task == 0)
- throw emptyTask(__FILE__, __LINE__);
+ throw EMPTYTASKEXCEPTION();
return m_task;
}
diff --git a/kmymoney/mymoney/onlinejobtyped.h b/kmymoney/mymoney/onlinejobtyped.h
--- a/kmymoney/mymoney/onlinejobtyped.h
+++ b/kmymoney/mymoney/onlinejobtyped.h
@@ -101,8 +101,8 @@
: onlineJob(task, id),
m_taskTyped(task)
{
- if (task == 0)
- throw emptyTask(__FILE__, __LINE__);
+ if (!task)
+ throw EMPTYTASKEXCEPTION();
}
template
@@ -127,8 +127,8 @@
: onlineJob(other)
{
m_taskTyped = dynamic_cast(onlineJob::task()); // can throw emptyTask
- if (m_taskTyped == 0)
- throw badTaskCast(__FILE__, __LINE__);
+ if (!m_taskTyped)
+ throw BADTASKEXCEPTION();
}
template
diff --git a/kmymoney/mymoney/payeeidentifier/payeeidentifier.h b/kmymoney/mymoney/payeeidentifier/payeeidentifier.h
--- a/kmymoney/mymoney/payeeidentifier/payeeidentifier.h
+++ b/kmymoney/mymoney/payeeidentifier/payeeidentifier.h
@@ -22,10 +22,14 @@
#include
#include
#include
+#include "mymoneyexception.h"
/** @todo fix include path after upgrade to cmake 3 */
#include "payeeidentifier/kmm_payeeidentifier_export.h"
+#define PAYEEIDENTIFIERBADCASTEXCEPTION(exceptionMessage) payeeIdentifier::badCast(QString::fromLatin1("Casted payeeIdentifier with wrong type %1:%2").arg(QString::fromLatin1(__FILE__), QString::number(__LINE__)))
+#define PAYEEIDENTIFIEREMPTYEXCEPTION(exceptionMessage) payeeIdentifier::empty(QString::fromLatin1("Requested payeeIdentifierData of empty payeeIdentifier %1:%2").arg(QString::fromLatin1(__FILE__), QString::number(__LINE__)))
+
// Q_DECLARE_METATYPE requries this include
class QDomDocument;
@@ -101,45 +105,24 @@
*/
QString iid() const;
- /**
- * @brief Base for exceptions thrown by payeeIdentifier
- *
- * @internal Using MyMoneyException instead is not possible because
- * it would lead to cyclic inter-target dependenies. We could create a new
- * shared library which includes MyMoneyException only, but this could be over-
- * powered.
- */
- class exception
- {};
-
/**
* @brief Thrown if a cast of a payeeIdentifier fails
*
* This is inspired by std::bad_cast
- * @todo inherit from MyMoneyException
*/
- class badCast : public exception
+ class badCast : public MyMoneyException
{
public:
- explicit badCast(const QString& file = "", const long unsigned int& line = 0)
- //: MyMoneyException("Casted payeeIdentifier with wrong type", file, line)
- {
- Q_UNUSED(file); Q_UNUSED(line);
- }
+ explicit badCast(const QString &exceptionMessage) : MyMoneyException(exceptionMessage) {}
};
/**
* @brief Thrown if one tried to access the data of a null payeeIdentifier
- * @todo inherit from MyMoneyException
*/
- class empty : public exception
+ class empty : public MyMoneyException
{
public:
- explicit empty(const QString& file = "", const long unsigned int& line = 0)
- //: MyMoneyException("Requested payeeIdentifierData of empty payeeIdentifier", file, line)
- {
- Q_UNUSED(file); Q_UNUSED(line);
- }
+ explicit empty(const QString &exceptionMessage) : MyMoneyException(exceptionMessage) {}
};
private:
@@ -160,7 +143,7 @@
{
T *const ident = dynamic_cast(operator->());
if (ident == 0)
- throw badCast(__FILE__, __LINE__);
+ throw PAYEEIDENTIFIERBADCASTEXCEPTION();
return ident;
}
@@ -169,7 +152,7 @@
{
const T *const ident = dynamic_cast(operator->());
if (ident == 0)
- throw badCast(__FILE__, __LINE__);
+ throw PAYEEIDENTIFIERBADCASTEXCEPTION();
return ident;
}
diff --git a/kmymoney/mymoney/payeeidentifier/payeeidentifier.cpp b/kmymoney/mymoney/payeeidentifier/payeeidentifier.cpp
--- a/kmymoney/mymoney/payeeidentifier/payeeidentifier.cpp
+++ b/kmymoney/mymoney/payeeidentifier/payeeidentifier.cpp
@@ -80,14 +80,14 @@
payeeIdentifierData* payeeIdentifier::operator->()
{
if (m_payeeIdentifier == 0)
- throw empty(__FILE__, __LINE__);
+ throw PAYEEIDENTIFIEREMPTYEXCEPTION();
return m_payeeIdentifier;
}
const payeeIdentifierData* payeeIdentifier::operator->() const
{
if (m_payeeIdentifier == 0)
- throw empty(__FILE__, __LINE__);
+ throw PAYEEIDENTIFIEREMPTYEXCEPTION();
return m_payeeIdentifier;
}
diff --git a/kmymoney/mymoney/payeeidentifier/payeeidentifiertyped.h b/kmymoney/mymoney/payeeidentifier/payeeidentifiertyped.h
--- a/kmymoney/mymoney/payeeidentifier/payeeidentifiertyped.h
+++ b/kmymoney/mymoney/payeeidentifier/payeeidentifiertyped.h
@@ -65,7 +65,7 @@
m_payeeIdentifierTyped(pid)
{
if (m_payeeIdentifierTyped == 0)
- throw payeeIdentifier::empty(__FILE__, __LINE__);
+ throw PAYEEIDENTIFIEREMPTYEXCEPTION();
}
template< class T >
@@ -98,8 +98,8 @@
m_payeeIdentifierTyped = dynamic_cast(payeeIdentifier::data());
if (m_payeeIdentifierTyped == 0) {
if (payeeIdentifier::data() == 0)
- throw payeeIdentifier::empty(__FILE__, __LINE__);
- throw payeeIdentifier::badCast(__FILE__, __LINE__);
+ throw PAYEEIDENTIFIEREMPTYEXCEPTION();
+ throw PAYEEIDENTIFIERBADCASTEXCEPTION();
}
}
diff --git a/kmymoney/mymoney/payeeidentifiermodel.cpp b/kmymoney/mymoney/payeeidentifiermodel.cpp
--- a/kmymoney/mymoney/payeeidentifiermodel.cpp
+++ b/kmymoney/mymoney/payeeidentifiermodel.cpp
@@ -68,7 +68,7 @@
if (index.isValid() && index.row() >= 0 && index.row() < m_payeeIdentifierIds.count()) {
try {
return MyMoneyFile::instance()->payee(m_payeeIdentifierIds.at(index.row()));
- } catch (MyMoneyException&) {
+ } catch (const MyMoneyException &) {
}
}
diff --git a/kmymoney/mymoney/storage/mymoneymap.h b/kmymoney/mymoney/storage/mymoneymap.h
--- a/kmymoney/mymoney/storage/mymoneymap.h
+++ b/kmymoney/mymoney/storage/mymoneymap.h
@@ -67,7 +67,7 @@
void rollbackTransaction(void) {
if (m_stack.isEmpty())
- throw MYMONEYEXCEPTION("No transaction started to rollback changes");
+ throw MYMONEYEXCEPTION(QStringLiteral("No transaction started to rollback changes"));
// undo all actions
MyMoneyMapAction* action;
@@ -80,7 +80,7 @@
bool commitTransaction(void) {
if (m_stack.isEmpty())
- throw MYMONEYEXCEPTION("No transaction started to commit changes");
+ throw MYMONEYEXCEPTION(QStringLiteral("No transaction started to commit changes"));
bool rc = m_stack.count() > 1;
// remove all actions from the stack
@@ -94,7 +94,7 @@
void insert(const Key& key, const T& obj) {
if (m_stack.isEmpty())
- throw MYMONEYEXCEPTION("No transaction started to insert new element into container");
+ throw MYMONEYEXCEPTION(QStringLiteral("No transaction started to insert new element into container"));
// check if information about the object identified by 'key'
// is already present in the stack
@@ -109,12 +109,12 @@
void modify(const Key& key, const T& obj) {
if (m_stack.isEmpty())
- throw MYMONEYEXCEPTION("No transaction started to modify element in container");
+ throw MYMONEYEXCEPTION(QStringLiteral("No transaction started to modify element in container"));
#if 0
// had to take this out, because we use QPair in one instance as key
if (key.isEmpty())
- throw MYMONEYEXCEPTION("No key to update object");
+ throw MYMONEYEXCEPTION(QStringLiteral("No key to update object"));
#endif
// check if information about the object identified by 'key'
@@ -129,12 +129,12 @@
void remove(const Key& key) {
if (m_stack.isEmpty())
- throw MYMONEYEXCEPTION("No transaction started to remove element from container");
+ throw MYMONEYEXCEPTION(QStringLiteral("No transaction started to remove element from container"));
#if 0
// had to take this out, because we use QPair in one instance as key
if (key.isEmpty())
- throw MYMONEYEXCEPTION("No key to remove object");
+ throw MYMONEYEXCEPTION(QStringLiteral("No key to remove object"));
#endif
// check if information about the object identified by 'key'
@@ -149,7 +149,7 @@
MyMoneyMap& operator= (const QMap& m) {
if (!m_stack.isEmpty()) {
- throw MYMONEYEXCEPTION("Cannot assign whole container during transaction");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot assign whole container during transaction"));
}
QMap::operator=(m);
return *this;
diff --git a/kmymoney/mymoney/storage/mymoneystorageanon.cpp b/kmymoney/mymoney/storage/mymoneystorageanon.cpp
--- a/kmymoney/mymoney/storage/mymoneystorageanon.cpp
+++ b/kmymoney/mymoney/storage/mymoneystorageanon.cpp
@@ -76,7 +76,7 @@
void MyMoneyStorageANON::readFile(QIODevice* , MyMoneyStorageMgr*)
{
- throw MYMONEYEXCEPTION("Cannot read a file through MyMoneyStorageANON!!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot read a file through MyMoneyStorageANON!!"));
}
void MyMoneyStorageANON::writeUserInformation(QDomElement& userInfo)
diff --git a/kmymoney/mymoney/storage/mymoneystoragemgr.cpp b/kmymoney/mymoney/storage/mymoneystoragemgr.cpp
--- a/kmymoney/mymoney/storage/mymoneystoragemgr.cpp
+++ b/kmymoney/mymoney/storage/mymoneystoragemgr.cpp
@@ -113,7 +113,7 @@
{
Q_D(MyMoneyStorageMgr);
if (!isStandardAccount(id))
- throw MYMONEYEXCEPTION("Only standard accounts can be modified using setAccountName()");
+ throw MYMONEYEXCEPTION(QStringLiteral("Only standard accounts can be modified using setAccountName()"));
auto acc = d->m_accountList[id];
acc.setName(name);
@@ -135,8 +135,7 @@
}
// throw an exception, if it does not exist
- const auto msg = QString::fromLatin1("Unknown account id '%1'").arg(id);
- throw MYMONEYEXCEPTION(msg);
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown account id '%1'").arg(id));
}
MyMoneyAccount MyMoneyStorageMgr::accountByName(const QString& name) const
@@ -153,7 +152,7 @@
}
}
- throw MYMONEYEXCEPTION("Unknown account '" + name + '\'');
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown account '%1'").arg(name));
}
void MyMoneyStorageMgr::accountList(QList& list) const
@@ -200,9 +199,9 @@
void MyMoneyStorageMgr::removeOnlineJob(const onlineJob& job)
{
Q_D(MyMoneyStorageMgr);
- if (!d->m_onlineJobList.contains(job.id())) {
- throw MYMONEYEXCEPTION("Unknown onlineJob '" + job.id() + "' should be removed.");
- }
+ if (!d->m_onlineJobList.contains(job.id()))
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown onlineJob '%1' should be removed.").arg(job.id()));
+
d->m_onlineJobList.remove(job.id());
}
@@ -210,9 +209,8 @@
{
Q_D(MyMoneyStorageMgr);
QMap::ConstIterator iter = d->m_onlineJobList.find(job.id());
- if (iter == d->m_onlineJobList.end()) {
- throw MYMONEYEXCEPTION("Got unknown onlineJob '" + job.id() + "' for modifying");
- }
+ if (iter == d->m_onlineJobList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Got unknown onlineJob '%1' for modifying").arg(job.id()));
onlineJob oldJob = iter.value();
d->m_onlineJobList.modify((*iter).id(), job);
}
@@ -223,7 +221,7 @@
if (d->m_onlineJobList.contains(id)) {
return d->m_onlineJobList[id];
}
- throw MYMONEYEXCEPTION("Unknown online Job '" + id + '\'');
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown online Job '%1'").arg(id));
}
ulong MyMoneyStorageMgr::onlineJobId() const
@@ -237,7 +235,7 @@
QMap::ConstIterator it;
it = d->m_payeeList.find(id);
if (it == d->m_payeeList.end())
- throw MYMONEYEXCEPTION("Unknown payee '" + id + '\'');
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown payee '%1'").arg(id));
return *it;
}
@@ -256,7 +254,7 @@
}
}
- throw MYMONEYEXCEPTION("Unknown payee '" + payee + '\'');
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown payee '%1'").arg(payee));
}
void MyMoneyStorageMgr::modifyPayee(const MyMoneyPayee& payee)
@@ -265,10 +263,9 @@
QMap::ConstIterator it;
it = d->m_payeeList.find(payee.id());
- if (it == d->m_payeeList.end()) {
- QString msg = "Unknown payee '" + payee.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_payeeList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown payee '%1'").arg(payee.id()));
+
d->m_payeeList.modify((*it).id(), payee);
}
@@ -280,22 +277,20 @@
QMap::ConstIterator it_p;
it_p = d->m_payeeList.find(payee.id());
- if (it_p == d->m_payeeList.end()) {
- QString msg = "Unknown payee '" + payee.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it_p == d->m_payeeList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown payee '%1'").arg(payee.id()));
// scan all transactions to check if the payee is still referenced
for (it_t = d->m_transactionList.begin(); it_t != d->m_transactionList.end(); ++it_t) {
if ((*it_t).hasReferenceTo(payee.id())) {
- throw MYMONEYEXCEPTION(QString("Cannot remove payee that is still referenced to a %1").arg("transaction"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot remove payee that is still referenced to a %1").arg("transaction"));
}
}
// check referential integrity in schedules
for (it_s = d->m_scheduleList.begin(); it_s != d->m_scheduleList.end(); ++it_s) {
if ((*it_s).hasReferenceTo(payee.id())) {
- throw MYMONEYEXCEPTION(QString("Cannot remove payee that is still referenced to a %1").arg("schedule"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot remove payee that is still referenced to a %1").arg("schedule"));
}
}
@@ -326,7 +321,7 @@
QMap::ConstIterator it;
it = d->m_tagList.find(id);
if (it == d->m_tagList.end())
- throw MYMONEYEXCEPTION("Unknown tag '" + id + '\'');
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown tag '%1'").arg(id));
return *it;
}
@@ -345,7 +340,7 @@
}
}
- throw MYMONEYEXCEPTION("Unknown tag '" + tag + '\'');
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown tag '%1'").arg(tag));
}
void MyMoneyStorageMgr::modifyTag(const MyMoneyTag& tag)
@@ -354,10 +349,9 @@
QMap::ConstIterator it;
it = d->m_tagList.find(tag.id());
- if (it == d->m_tagList.end()) {
- QString msg = "Unknown tag '" + tag.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_tagList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown tag '%1'").arg(tag.id()));
+
d->m_tagList.modify((*it).id(), tag);
}
@@ -369,22 +363,20 @@
QMap::ConstIterator it_ta;
it_ta = d->m_tagList.find(tag.id());
- if (it_ta == d->m_tagList.end()) {
- QString msg = "Unknown tag '" + tag.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it_ta == d->m_tagList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown tag '%1'").arg(tag.id()));
// scan all transactions to check if the tag is still referenced
for (it_t = d->m_transactionList.begin(); it_t != d->m_transactionList.end(); ++it_t) {
if ((*it_t).hasReferenceTo(tag.id())) {
- throw MYMONEYEXCEPTION(QString("Cannot remove tag that is still referenced to a %1").arg("transaction"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot remove tag that is still referenced to a %1").arg("transaction"));
}
}
// check referential integrity in schedules
for (it_s = d->m_scheduleList.begin(); it_s != d->m_scheduleList.end(); ++it_s) {
if ((*it_s).hasReferenceTo(tag.id())) {
- throw MYMONEYEXCEPTION(QString("Cannot remove tag that is still referenced to a %1").arg("schedule"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot remove tag that is still referenced to a %1").arg("schedule"));
}
}
@@ -407,18 +399,12 @@
QMap::ConstIterator theChild;
theParent = d->m_accountList.find(parent.id());
- if (theParent == d->m_accountList.end()) {
- QString msg = "Unknown parent account '";
- msg += parent.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (theParent == d->m_accountList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown parent account '%1'").arg(parent.id()));
theChild = d->m_accountList.find(account.id());
- if (theChild == d->m_accountList.end()) {
- QString msg = "Unknown child account '";
- msg += account.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (theChild == d->m_accountList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown child account '%1'").arg(account.id()));
auto acc = *theParent;
acc.addAccountId(account.id());
@@ -515,9 +501,9 @@
// first perform all the checks
if (!transaction.id().isEmpty())
- throw MYMONEYEXCEPTION("transaction already contains an id");
+ throw MYMONEYEXCEPTION(QStringLiteral("transaction already contains an id"));
if (!transaction.postDate().isValid())
- throw MYMONEYEXCEPTION("invalid post date");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid post date"));
// now check the splits
foreach (const auto split, transaction.splits()) {
@@ -568,7 +554,7 @@
pos = d->m_institutionList.find(id);
if (pos != d->m_institutionList.end())
return *pos;
- throw MYMONEYEXCEPTION("unknown institution");
+ throw MYMONEYEXCEPTION(QStringLiteral("unknown institution"));
}
bool MyMoneyStorageMgr::dirty() const
@@ -615,10 +601,10 @@
d->m_accountList.modify(account.id(), account);
} else
- throw MYMONEYEXCEPTION("Invalid information for update");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid information for update"));
} else
- throw MYMONEYEXCEPTION("Unknown account id");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unknown account id"));
}
void MyMoneyStorageMgr::modifyInstitution(const MyMoneyInstitution& institution)
@@ -632,7 +618,7 @@
d->m_institutionList.modify(institution.id(), institution);
} else
- throw MYMONEYEXCEPTION("unknown institution");
+ throw MYMONEYEXCEPTION(QStringLiteral("unknown institution"));
}
void MyMoneyStorageMgr::modifyTransaction(const MyMoneyTransaction& transaction)
@@ -649,7 +635,7 @@
if (transaction.id().isEmpty()
// || transaction.file() != this
|| !transaction.postDate().isValid())
- throw MYMONEYEXCEPTION("invalid transaction to be modified");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid transaction to be modified"));
// now check the splits
foreach (const auto split, transaction.splits()) {
@@ -667,17 +653,17 @@
// new data seems to be ok. find old version of transaction
// in our pool. Throw exception if unknown.
if (!d->m_transactionKeys.contains(transaction.id()))
- throw MYMONEYEXCEPTION("invalid transaction id");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid transaction id"));
QString oldKey = d->m_transactionKeys[transaction.id()];
if (!d->m_transactionList.contains(oldKey))
- throw MYMONEYEXCEPTION("invalid transaction key");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid transaction key"));
QMap::ConstIterator it_t;
it_t = d->m_transactionList.find(oldKey);
if (it_t == d->m_transactionList.end())
- throw MYMONEYEXCEPTION("invalid transaction key");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid transaction key"));
foreach (const auto split, (*it_t).splits()) {
auto acc = d->m_accountList[split.accountId()];
@@ -723,18 +709,18 @@
Q_D(MyMoneyStorageMgr);
// first perform all the checks
if (transaction.id().isEmpty())
- throw MYMONEYEXCEPTION("invalid transaction to be deleted");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid transaction to be deleted"));
QMap::ConstIterator it_k;
QMap::ConstIterator it_t;
it_k = d->m_transactionKeys.find(transaction.id());
if (it_k == d->m_transactionKeys.end())
- throw MYMONEYEXCEPTION("invalid transaction to be deleted");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid transaction to be deleted"));
it_t = d->m_transactionList.find(*it_k);
if (it_t == d->m_transactionList.end())
- throw MYMONEYEXCEPTION("invalid transaction key");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid transaction key"));
// keep a copy so that we still have the data after removal
MyMoneyTransaction t(*it_t);
@@ -768,10 +754,10 @@
// check that it's not one of the standard account groups
if (isStandardAccount(account.id()))
- throw MYMONEYEXCEPTION("Unable to remove the standard account groups");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to remove the standard account groups"));
if (hasActiveSplits(account.id())) {
- throw MYMONEYEXCEPTION("Unable to remove account with active splits");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unable to remove account with active splits"));
}
// re-parent all sub-ordinate accounts to the parent of the account
@@ -791,14 +777,14 @@
it_a = d->m_accountList.find(account.id());
if (it_a == d->m_accountList.end())
- throw MYMONEYEXCEPTION("Internal error: account not found in list");
+ throw MYMONEYEXCEPTION(QStringLiteral("Internal error: account not found in list"));
it_p = d->m_accountList.find(parent.id());
if (it_p == d->m_accountList.end())
- throw MYMONEYEXCEPTION("Internal error: parent account not found in list");
+ throw MYMONEYEXCEPTION(QStringLiteral("Internal error: parent account not found in list"));
if (!account.institutionId().isEmpty())
- throw MYMONEYEXCEPTION("Cannot remove account still attached to an institution");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot remove account still attached to an institution"));
d->removeReferences(account.id());
@@ -838,7 +824,7 @@
d->m_institutionList.remove(institution.id());
} else
- throw MYMONEYEXCEPTION("invalid institution");
+ throw MYMONEYEXCEPTION(QStringLiteral("invalid institution"));
}
void MyMoneyStorageMgr::transactionList(QList& list, MyMoneyTransactionFilter& filter) const
@@ -892,10 +878,8 @@
MyMoneyCostCenter MyMoneyStorageMgr::costCenter(const QString& id) const
{
Q_D(const MyMoneyStorageMgr);
- if (!d->m_costCenterList.contains(id)) {
- QString msg = QString("Invalid cost center id '%1'").arg(id);
- throw MYMONEYEXCEPTION(msg);
- }
+ if (!d->m_costCenterList.contains(id))
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid cost center id '%1'").arg(id));
return d->m_costCenterList[id];
}
@@ -911,16 +895,13 @@
// get the full key of this transaction, throw exception
// if it's invalid (unknown)
if (!d->m_transactionKeys.contains(id)) {
- QString msg = QString("Invalid transaction id '%1'").arg(id);
- throw MYMONEYEXCEPTION(msg);
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid transaction id '%1'").arg(id));
}
// check if this key is in the list, throw exception if not
QString key = d->m_transactionKeys[id];
- if (!d->m_transactionList.contains(key)) {
- QString msg = QString("Invalid transaction key '%1'").arg(key);
- throw MYMONEYEXCEPTION(msg);
- }
+ if (!d->m_transactionList.contains(key))
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid transaction key '%1'").arg(key));
return d->m_transactionList[key];
}
@@ -934,7 +915,7 @@
// find account object in list, throw exception if unknown
acc = m_accountList.find(account);
if(acc == m_accountList.end())
- throw MYMONEYEXCEPTION("unknown account id");
+ throw MYMONEYEXCEPTION(QStringLiteral("unknown account id"));
// get the transaction info from the account
MyMoneyAccount::Transaction t = (*acc).transaction(idx);
@@ -955,7 +936,7 @@
const auto list = transactionList(filter);
if (idx < 0 || idx >= static_cast(list.count()))
- throw MYMONEYEXCEPTION("Unknown idx for transaction");
+ throw MYMONEYEXCEPTION(QStringLiteral("Unknown idx for transaction"));
return transaction(list[idx].id());
}
@@ -964,7 +945,7 @@
{
Q_D(const MyMoneyStorageMgr);
if (!d->m_accountList.contains(id))
- throw MYMONEYEXCEPTION(QString("Unknown account id '%1'").arg(id));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown account id '%1'").arg(id));
// the balance of all transactions for this account has
// been requested. no need to calculate anything as we
@@ -1206,7 +1187,7 @@
Q_D(MyMoneyStorageMgr);
// first perform all the checks
if (!sched.id().isEmpty())
- throw MYMONEYEXCEPTION("schedule already contains an id");
+ throw MYMONEYEXCEPTION(QStringLiteral("schedule already contains an id"));
// The following will throw an exception when it fails
sched.validate(false);
@@ -1215,7 +1196,7 @@
const auto splits = sched.transaction().splits();
for (const auto& split : splits)
if (!d->m_accountList.contains(split.accountId()))
- throw MYMONEYEXCEPTION("bad account id");
+ throw MYMONEYEXCEPTION(QStringLiteral("bad account id"));
MyMoneySchedule newSched(d->nextScheduleID(), sched);
d->m_scheduleList.insert(newSched.id(), newSched);
@@ -1228,10 +1209,8 @@
QMap::ConstIterator it;
it = d->m_scheduleList.find(sched.id());
- if (it == d->m_scheduleList.end()) {
- QString msg = "Unknown schedule '" + sched.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_scheduleList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown schedule '%1'").arg(sched.id()));
d->m_scheduleList.modify(sched.id(), sched);
}
@@ -1242,10 +1221,8 @@
QMap::ConstIterator it;
it = d->m_scheduleList.find(sched.id());
- if (it == d->m_scheduleList.end()) {
- QString msg = "Unknown schedule '" + sched.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_scheduleList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown schedule '%1'").arg(sched.id()));
// FIXME: check referential integrity for loan accounts
d->m_scheduleList.remove(sched.id());
@@ -1262,8 +1239,7 @@
return (*pos);
// throw an exception, if it does not exist
- QString msg = "Unknown schedule id '" + id + '\'';
- throw MYMONEYEXCEPTION(msg);
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown schedule '%1'").arg(id));
}
QList MyMoneyStorageMgr::scheduleList(const QString& accountId,
@@ -1426,11 +1402,8 @@
QMap::ConstIterator it;
it = d->m_securitiesList.find(security.id());
- if (it == d->m_securitiesList.end()) {
- QString msg = "Unknown security '";
- msg += security.id() + "' during modifySecurity()";
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_securitiesList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown security '%1'").arg(security.id()));
d->m_securitiesList.modify(security.id(), security);
}
@@ -1443,11 +1416,8 @@
// FIXME: check referential integrity
it = d->m_securitiesList.find(security.id());
- if (it == d->m_securitiesList.end()) {
- QString msg = "Unknown security '";
- msg += security.id() + "' during removeSecurity()";
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_securitiesList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown security '%1'").arg(security.id()));
d->m_securitiesList.remove(security.id());
}
@@ -1482,9 +1452,8 @@
QMap::ConstIterator it;
it = d->m_currencyList.find(currency.id());
- if (it != d->m_currencyList.end()) {
- throw MYMONEYEXCEPTION(i18n("Cannot add currency with existing id %1", currency.id()));
- }
+ if (it != d->m_currencyList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot add currency with existing id %1").arg(currency.id()));
d->m_currencyList.insert(currency.id(), currency);
}
@@ -1495,9 +1464,8 @@
QMap::ConstIterator it;
it = d->m_currencyList.find(currency.id());
- if (it == d->m_currencyList.end()) {
- throw MYMONEYEXCEPTION(i18n("Cannot modify currency with unknown id %1", currency.id()));
- }
+ if (it == d->m_currencyList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot modify currency with unknown id %1").arg(currency.id()));
d->m_currencyList.modify(currency.id(), currency);
}
@@ -1510,9 +1478,8 @@
// FIXME: check referential integrity
it = d->m_currencyList.find(currency.id());
- if (it == d->m_currencyList.end()) {
- throw MYMONEYEXCEPTION(i18n("Cannot remove currency with unknown id %1", currency.id()));
- }
+ if (it == d->m_currencyList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot remove currency with unknown id %1").arg(currency.id()));
d->m_currencyList.remove(currency.id());
}
@@ -1526,9 +1493,8 @@
QMap::ConstIterator it;
it = d->m_currencyList.find(id);
- if (it == d->m_currencyList.end()) {
- throw MYMONEYEXCEPTION(i18n("Cannot retrieve currency with unknown id '%1'", id));
- }
+ if (it == d->m_currencyList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot retrieve currency with unknown id '%1'").arg(id));
return *it;
}
@@ -1549,7 +1515,7 @@
{
Q_D(MyMoneyStorageMgr);
if (!report.id().isEmpty())
- throw MYMONEYEXCEPTION("report already contains an id");
+ throw MYMONEYEXCEPTION(QString::fromLatin1("report already contains an id"));
MyMoneyReport newReport(d->nextReportID(), report);
d->m_reportList.insert(newReport.id(), newReport);
@@ -1581,10 +1547,9 @@
QMap::ConstIterator it;
it = d->m_reportList.find(report.id());
- if (it == d->m_reportList.end()) {
- QString msg = "Unknown report '" + report.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_reportList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown report '%1'").arg(report.id()));
+
d->m_reportList.modify(report.id(), report);
}
@@ -1606,10 +1571,8 @@
QMap::ConstIterator it;
it = d->m_reportList.find(report.id());
- if (it == d->m_reportList.end()) {
- QString msg = "Unknown report '" + report.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_reportList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown report '%1'").arg(report.id()));
d->m_reportList.remove(report.id());
}
@@ -1659,7 +1622,7 @@
}
}
- throw MYMONEYEXCEPTION("Unknown budget '" + budget + '\'');
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown budget '%1'").arg(budget));
}
void MyMoneyStorageMgr::modifyBudget(const MyMoneyBudget& budget)
@@ -1668,10 +1631,9 @@
QMap::ConstIterator it;
it = d->m_budgetList.find(budget.id());
- if (it == d->m_budgetList.end()) {
- QString msg = "Unknown budget '" + budget.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_budgetList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown budget '%1'").arg(budget.id()));
+
d->m_budgetList.modify(budget.id(), budget);
}
@@ -1693,10 +1655,8 @@
QMap::ConstIterator it;
it = d->m_budgetList.find(budget.id());
- if (it == d->m_budgetList.end()) {
- QString msg = "Unknown budget '" + budget.id() + '\'';
- throw MYMONEYEXCEPTION(msg);
- }
+ if (it == d->m_budgetList.end())
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown budget '%1'").arg(budget.id()));
d->m_budgetList.remove(budget.id());
}
diff --git a/kmymoney/mymoney/storage/mymoneystoragemgr_p.h b/kmymoney/mymoney/storage/mymoneystoragemgr_p.h
--- a/kmymoney/mymoney/storage/mymoneystoragemgr_p.h
+++ b/kmymoney/mymoney/storage/mymoneystoragemgr_p.h
@@ -193,7 +193,7 @@
}
if (account.accountType() == eMyMoney::Account::Type::Stock && parent.accountType() != eMyMoney::Account::Type::Investment)
- throw MYMONEYEXCEPTION("Cannot move a stock acocunt into a non-investment account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Cannot move a stock acocunt into a non-investment account"));
newParent = m_accountList.find(parent.id());
childAccount = m_accountList.find(account.id());
diff --git a/kmymoney/mymoney/storage/mymoneystoragexml.cpp b/kmymoney/mymoney/storage/mymoneystoragexml.cpp
--- a/kmymoney/mymoney/storage/mymoneystoragexml.cpp
+++ b/kmymoney/mymoney/storage/mymoneystoragexml.cpp
@@ -491,7 +491,7 @@
delete m_doc;
m_doc = 0;
signalProgress(-1, -1);
- throw MYMONEYEXCEPTION("File was not parsable!");
+ throw MYMONEYEXCEPTION(QStringLiteral("File was not parsable!"));
}
// check if we need to build up the account balances
diff --git a/kmymoney/mymoney/tests/mymoneyexception-test.h b/kmymoney/mymoney/tests/mymoneyexception-test.h
--- a/kmymoney/mymoney/tests/mymoneyexception-test.h
+++ b/kmymoney/mymoney/tests/mymoneyexception-test.h
@@ -19,7 +19,6 @@
#include
-#include "mymoneyutils.h"
#include "mymoneyexception.h"
class MyMoneyExceptionTest : public QObject
@@ -31,8 +30,5 @@
void cleanup();
void testDefaultConstructor();
-
- void testConstructor();
-
};
#endif
diff --git a/kmymoney/mymoney/tests/mymoneyexception-test.cpp b/kmymoney/mymoney/tests/mymoneyexception-test.cpp
--- a/kmymoney/mymoney/tests/mymoneyexception-test.cpp
+++ b/kmymoney/mymoney/tests/mymoneyexception-test.cpp
@@ -31,16 +31,8 @@
void MyMoneyExceptionTest::testDefaultConstructor()
{
- const MyMoneyException &e = MYMONEYEXCEPTION("Message");
- QVERIFY(e.what() == "Message");
- QVERIFY(e.line() == __LINE__ - 2);
- QVERIFY(e.file() == __FILE__);
-}
-
-void MyMoneyExceptionTest::testConstructor()
-{
- MyMoneyException e("New message", "Joe's file", 1234);
- QVERIFY(e.what() == "New message");
- QVERIFY(e.line() == 1234);
- QVERIFY(e.file() == "Joe's file");
+ const MyMoneyException &e = MYMONEYEXCEPTION(QStringLiteral("Message"));
+ QVERIFY(e.what().startsWith("Message"));
+ QVERIFY(e.what().contains(QString::number(__LINE__ - 2)));
+ QVERIFY(e.what().contains(QString::fromLatin1(__FILE__)));
}
diff --git a/kmymoney/mymoney/tests/mymoneyfile-test.cpp b/kmymoney/mymoney/tests/mymoneyfile-test.cpp
--- a/kmymoney/mymoney/tests/mymoneyfile-test.cpp
+++ b/kmymoney/mymoney/tests/mymoneyfile-test.cpp
@@ -1289,7 +1289,7 @@
QCOMPARE(m->account("A000001").transactionCount(), 0);
QCOMPARE(m->account("A000002").transactionCount(), 1);
QCOMPARE(m->account("A000003").transactionCount(), 1);
- } catch(const MyMoneyException &e) {
+ } catch (const MyMoneyException &e) {
QFAIL("Unexpected exception!");
}
}
@@ -1553,7 +1553,7 @@
QFAIL("Unexpected exception");
}
QCOMPARE(iban->electronicIban(), QLatin1String("DE82200700240066644600"));
- } catch (const MyMoneyException& e) {
+ } catch (const MyMoneyException &e) {
unexpectedException(e);
}
}
diff --git a/kmymoney/mymoney/tests/mymoneyforecast-test.cpp b/kmymoney/mymoney/tests/mymoneyforecast-test.cpp
--- a/kmymoney/mymoney/tests/mymoneyforecast-test.cpp
+++ b/kmymoney/mymoney/tests/mymoneyforecast-test.cpp
@@ -52,7 +52,7 @@
this->moT3 = MyMoneyMoney(84, 1);
this->moT4 = MyMoneyMoney(62, 1);
this->moT5 = MyMoneyMoney(104, 1);
- } catch (const MyMoneyException & e) {
+ } catch (const MyMoneyException &e) {
qDebug() << e.what();
}
}
@@ -287,12 +287,12 @@
try {
MyMoneyForecast::calculateAccountTrend(a_checking, 0);
} catch (const MyMoneyException &e) {
- QVERIFY(e.what().compare("Illegal arguments when calling calculateAccountTrend. trendDays must be higher than 0") == 0);
+ QVERIFY(e.what().startsWith("Illegal arguments when calling calculateAccountTrend. trendDays must be higher than 0"));
}
try {
MyMoneyForecast::calculateAccountTrend(a_checking, -10);
} catch (const MyMoneyException &e) {
- QVERIFY(e.what().compare("Illegal arguments when calling calculateAccountTrend. trendDays must be higher than 0") == 0);
+ QVERIFY(e.what().startsWith("Illegal arguments when calling calculateAccountTrend. trendDays must be higher than 0"));
}
//test that it calculates correctly
diff --git a/kmymoney/mymoney/tests/mymoneytestutils.cpp b/kmymoney/mymoney/tests/mymoneytestutils.cpp
--- a/kmymoney/mymoney/tests/mymoneytestutils.cpp
+++ b/kmymoney/mymoney/tests/mymoneytestutils.cpp
@@ -20,9 +20,6 @@
QString unexpectedExceptionString(const MyMoneyException &e)
{
- return QString("Unexpected exception: %1 thrown in %2:%3")
- .arg(e.what())
- .arg(e.file())
- .arg(e.line());
+ return QString("Unexpected exception: %1").arg(e.what());
}
diff --git a/kmymoney/mymoney/tests/onlinejobadministration-test.cpp b/kmymoney/mymoney/tests/onlinejobadministration-test.cpp
--- a/kmymoney/mymoney/tests/onlinejobadministration-test.cpp
+++ b/kmymoney/mymoney/tests/onlinejobadministration-test.cpp
@@ -50,8 +50,8 @@
file->addAccount(account , asset);
accountId = account.id();
transaction.commit();
- } catch (const MyMoneyException& ex) {
- QFAIL(qPrintable("Unexpected exception " + ex.what()));
+ } catch (const MyMoneyException &ex) {
+ QFAIL(qPrintable(QString::fromLatin1("Unexpected exception %1").arg(ex.what())));
}
}
diff --git a/kmymoney/payeeidentifier/ibanandbic/widgets/ibanbicitemedit.cpp b/kmymoney/payeeidentifier/ibanandbic/widgets/ibanbicitemedit.cpp
--- a/kmymoney/payeeidentifier/ibanandbic/widgets/ibanbicitemedit.cpp
+++ b/kmymoney/payeeidentifier/ibanandbic/widgets/ibanbicitemedit.cpp
@@ -73,7 +73,8 @@
d->ui->bicEdit->setText(identTyped->storedBic());
d->ui->ibanEdit->setText(identTyped->paperformatIban());
d->m_identifier = ident;
- } catch (payeeIdentifier::exception&) {
+ } catch (const payeeIdentifier::empty &) {
+ } catch (const payeeIdentifier::badCast &) {
}
}
diff --git a/kmymoney/payeeidentifier/nationalaccount/ui/nationalaccountedit.cpp b/kmymoney/payeeidentifier/nationalaccount/ui/nationalaccountedit.cpp
--- a/kmymoney/payeeidentifier/nationalaccount/ui/nationalaccountedit.cpp
+++ b/kmymoney/payeeidentifier/nationalaccount/ui/nationalaccountedit.cpp
@@ -49,7 +49,8 @@
payeeIdentifierTyped ident(d->m_identifier);
ident->setAccountNumber(d->ui.accountNumberEdit->text());
ident->setBankCode(d->ui.institutionCodeEdit->text());
- } catch (payeeIdentifier::exception&) {
+ } catch (const payeeIdentifier::empty &) {
+ } catch (const payeeIdentifier::badCast &) {
}
}
return d->m_identifier;
@@ -78,7 +79,8 @@
d->ui.accountNumberEdit->setText(identTyped->accountNumber());
d->ui.institutionCodeEdit->setText(identTyped->bankCode());
d->m_identifier = ident;
- } catch (payeeIdentifier::exception&) {
+ } catch (const payeeIdentifier::empty &) {
+ } catch (const payeeIdentifier::badCast &) {
}
}
diff --git a/kmymoney/plugins/csv/export/csvwriter.cpp b/kmymoney/plugins/csv/export/csvwriter.cpp
--- a/kmymoney/plugins/csv/export/csvwriter.cpp
+++ b/kmymoney/plugins/csv/export/csvwriter.cpp
@@ -82,10 +82,7 @@
emit signalProgress(-1, -1);
} catch (const MyMoneyException &e) {
- QString errMsg = i18n("Unexpected exception '%1' thrown in %2, line %3 "
- "caught in MyMoneyCsvWriter::write()", e.what(), e.file(), e.line());
-
- KMessageBox::error(0, errMsg);
+ KMessageBox::error(nullptr, i18n("Unexpected exception '%1'", e.what()));
}
csvFile.close();
diff --git a/kmymoney/plugins/gnc/import/mymoneygncreader.cpp b/kmymoney/plugins/gnc/import/mymoneygncreader.cpp
--- a/kmymoney/plugins/gnc/import/mymoneygncreader.cpp
+++ b/kmymoney/plugins/gnc/import/mymoneygncreader.cpp
@@ -149,11 +149,8 @@
{
TRY {
if (map.contains(elName)) { // if it's not in the map, there's nothing to check
- if (!map[elName].contains(elAttrs.value("version"))) {
- QString em = Q_FUNC_INFO + i18n(": Sorry. This importer cannot handle version %1 of element %2"
- , elAttrs.value("version"), elName);
- throw MYMONEYEXCEPTION(em);
- }
+ if (!map[elName].contains(elAttrs.value("version")))
+ throw MYMONEYEXCEPTION(QString::fromLatin1("%1 : Sorry. This importer cannot handle version %2 of element %3").arg(Q_FUNC_INFO, elAttrs.value("version"), elName));
}
return ;
}
@@ -338,7 +335,7 @@
GncObject *next = 0;
switch (m_state) {
case BOOK:
- if (m_bookFound) throw MYMONEYEXCEPTION(i18n("This version of the importer cannot handle multi-book files."));
+ if (m_bookFound) MYMONEYEXCEPTION(QString::fromLatin1("This version of the importer cannot handle multi-book files."));
m_bookFound = true;
break;
case COUNT:
@@ -365,7 +362,7 @@
next = new GncSchedule;
break;
default:
- throw MYMONEYEXCEPTION("GncFile rcvd invalid state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncFile rcvd invalid state"));
}
return (next);
}
@@ -457,7 +454,7 @@
next = new GncKvp;
break;
default:
- throw MYMONEYEXCEPTION("GncKvp rcvd invalid m_state ");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncKvp rcvd invalid m_state "));
}
return (next);
}
@@ -578,7 +575,7 @@
next = new GncDate;
break;
default:
- throw MYMONEYEXCEPTION("GncPrice rcvd invalid m_state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncPrice rcvd invalid m_state"));
}
return (next);
}
@@ -599,7 +596,7 @@
m_vpPriceDate = static_cast(subObj);
break;
default:
- throw MYMONEYEXCEPTION("GncPrice rcvd invalid m_state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncPrice rcvd invalid m_state"));
}
return;
}
@@ -653,7 +650,7 @@
pMain->setLotsFound(true); // we don't handle lots; just set flag to report
break;
default:
- throw MYMONEYEXCEPTION("GncAccount rcvd invalid m_state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncAccount rcvd invalid m_state"));
}
return (next);
}
@@ -730,7 +727,7 @@
next = new GncKvp;
break;
default:
- throw MYMONEYEXCEPTION("GncTransaction rcvd invalid m_state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncTransaction rcvd invalid m_state"));
}
return (next);
}
@@ -802,7 +799,7 @@
next = new GncDate;
break;
default:
- throw MYMONEYEXCEPTION("GncTemplateSplit rcvd invalid m_state ");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncTemplateSplit rcvd invalid m_state "));
}
return (next);
}
@@ -847,7 +844,7 @@
next = new GncKvp;
break;
default:
- throw MYMONEYEXCEPTION("GncTemplateSplit rcvd invalid m_state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncTemplateSplit rcvd invalid m_state"));
}
return (next);
}
@@ -909,7 +906,7 @@
next = new GncSchedDef;
break;
default:
- throw MYMONEYEXCEPTION("GncSchedule rcvd invalid m_state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncSchedule rcvd invalid m_state"));
}
return (next);
}
@@ -979,7 +976,7 @@
next = new GncFreqSpec;
break;
default:
- throw MYMONEYEXCEPTION("GncFreqSpec rcvd invalid m_state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncFreqSpec rcvd invalid m_state"));
}
return (next);
}
@@ -1034,7 +1031,7 @@
next = new GncDate;
break;
default:
- throw MYMONEYEXCEPTION("GncRecurrence rcvd invalid m_state");
+ throw MYMONEYEXCEPTION(QStringLiteral("GncRecurrence rcvd invalid m_state"));
}
return (next);
}
@@ -1110,9 +1107,9 @@
m_reader = new QXmlSimpleReader;
m_reader->setContentHandler(this);
// go read the file
- if (!m_reader->parse(m_source)) {
- throw MYMONEYEXCEPTION(i18n("Input file cannot be parsed; may be corrupt\n%1", errorString()));
- }
+ if (!m_reader->parse(m_source))
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Input file cannot be parsed; may be corrupt\n%1").arg(errorString()));
+
delete m_reader;
delete m_source;
return ;
@@ -1162,7 +1159,7 @@
lastType = 0;
#else
if ((!m_headerFound) && (elName != "gnc-v2"))
- throw MYMONEYEXCEPTION(i18n("Invalid header for file. Should be 'gnc-v2'"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Invalid header for file. Should be 'gnc-v2'"));
m_headerFound = true;
#endif // _GNCFILEANON
m_co->checkVersion(elName, elAttrs, pMain->m_versionList);
@@ -1548,9 +1545,7 @@
} else if ("MONEYMRKT" == gac->type()) {
acc.setAccountType(Account::Type::MoneyMarket);
} else { // we have here an account type we can't currently handle
- QString em =
- i18n("Current importer does not recognize GnuCash account type %1", gac->type());
- throw MYMONEYEXCEPTION(em);
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Current importer does not recognize GnuCash account type %1").arg(gac->type()));
}
// if no parent account is present, assign to one of our standard accounts
if ((acc.parentAccountId().isEmpty()) || (acc.parentAccountId() == m_rootId)) {
@@ -2030,7 +2025,7 @@
if (static_cast((*itt)->getSplit(0))->acct() == gsc->templId()) break;
}
if (itt == m_templateList.constEnd()) {
- throw MYMONEYEXCEPTION(i18n("Cannot find template transaction for schedule %1", sc.name()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Cannot find template transaction for schedule %1").arg(sc.name()));
} else {
tx = convertTemplateTransaction(sc.name(), *itt);
}
@@ -2257,7 +2252,7 @@
parent = checkConsistency(parent, (*acc));
m_storage->addAccount(parent, (*acc));
} else {
- throw MYMONEYEXCEPTION("terminate() could not find account id");
+ throw MYMONEYEXCEPTION(QStringLiteral("terminate() could not find account id"));
}
}
signalProgress(++i, 0);
@@ -2455,7 +2450,7 @@
case 'o': // once-only
return (lastDate);
}
- throw MYMONEYEXCEPTION(i18n("Internal error - invalid interval char in incrDate"));
+ throw MYMONEYEXCEPTION(QStringLiteral("Internal error - invalid interval char in incrDate"));
// QDate r = QDate(); return (r); // to keep compiler happy
}
PASS
diff --git a/kmymoney/plugins/interfaces/kmmstatementinterface.cpp b/kmymoney/plugins/interfaces/kmmstatementinterface.cpp
--- a/kmymoney/plugins/interfaces/kmmstatementinterface.cpp
+++ b/kmymoney/plugins/interfaces/kmmstatementinterface.cpp
@@ -81,7 +81,7 @@
MyMoneyFile::instance()->modifyAccount(oAcc);
ft.commit();
- } catch (const MyMoneyException) {
+ } catch (const MyMoneyException &) {
qDebug("Unable to setup online parameters for account '%s'", qPrintable(acc.name()));
// KMessageBox::detailedSorry(0, i18n("Unable to setup online parameters for account '%1'", acc.name()), e.what());
}
diff --git a/kmymoney/plugins/kbanking/kbanking.cpp b/kmymoney/plugins/kbanking/kbanking.cpp
--- a/kmymoney/plugins/kbanking/kbanking.cpp
+++ b/kmymoney/plugins/kbanking/kbanking.cpp
@@ -664,7 +664,7 @@
d->jobList.clear();
d->fileId = id;
}
- } catch (const MyMoneyException&) {
+ } catch (const MyMoneyException &) {
// Exception usually means account was not found
return QStringList();
}
diff --git a/kmymoney/plugins/onlinejobpluginmockup/onlinejobpluginmockup.cpp b/kmymoney/plugins/onlinejobpluginmockup/onlinejobpluginmockup.cpp
--- a/kmymoney/plugins/onlinejobpluginmockup/onlinejobpluginmockup.cpp
+++ b/kmymoney/plugins/onlinejobpluginmockup/onlinejobpluginmockup.cpp
@@ -77,7 +77,7 @@
try {
if (MyMoneyFile::instance()->account(accountId).onlineBankingSettings().value("provider").toLower() == objectName().toLower())
return onlineJobAdministration::instance()->availableOnlineTasks();
- } catch (MyMoneyException&) {
+ } catch (const MyMoneyException &) {
}
return QStringList();
@@ -88,7 +88,7 @@
try {
if (taskName == sepaOnlineTransfer::name() && MyMoneyFile::instance()->account(accountId).onlineBankingSettings().value("provider").toLower() == objectName().toLower())
return IonlineTaskSettings::ptr(new sepaCreditTransferSettingsMockup);
- } catch (MyMoneyException&) {
+ } catch (const MyMoneyException &) {
}
return IonlineTaskSettings::ptr();
}
diff --git a/kmymoney/plugins/onlinetasks/sepa/tasks/sepaonlinetransferimpl.cpp b/kmymoney/plugins/onlinetasks/sepa/tasks/sepaonlinetransferimpl.cpp
--- a/kmymoney/plugins/onlinetasks/sepa/tasks/sepaonlinetransferimpl.cpp
+++ b/kmymoney/plugins/onlinetasks/sepa/tasks/sepaonlinetransferimpl.cpp
@@ -156,7 +156,8 @@
try {
payeeIdentifier ident = originAccountIdentifier();
iban = ident.data()->electronicIban();
- } catch (payeeIdentifier::exception&) {
+ } catch (const payeeIdentifier::empty &) {
+ } catch (const payeeIdentifier::badCast &) {
}
QSharedPointer localSettings = getSettings();
diff --git a/kmymoney/plugins/onlinetasks/sepa/ui/sepacredittransferedit.cpp b/kmymoney/plugins/onlinetasks/sepa/ui/sepacredittransferedit.cpp
--- a/kmymoney/plugins/onlinetasks/sepa/ui/sepacredittransferedit.cpp
+++ b/kmymoney/plugins/onlinetasks/sepa/ui/sepacredittransferedit.cpp
@@ -114,7 +114,9 @@
index.model()->data(index, payeeIdentifierModel::payeeIdentifier).value()
);
return iban->electronicIban();
- } catch (payeeIdentifier::exception&) {
+ } catch (const payeeIdentifier::empty &) {
+ return QVariant();
+ } catch (const payeeIdentifier::badCast &) {
return QVariant();
}
}
@@ -172,7 +174,8 @@
);
emit activatedIban(iban->electronicIban());
emit activatedBic(iban->storedBic());
- } catch (payeeIdentifier::exception&) {
+ } catch (const payeeIdentifier::empty &) {
+ } catch (const payeeIdentifier::badCast &) {
}
}
@@ -188,7 +191,8 @@
);
emit highlightedIban(iban->electronicIban());
emit highlightedBic(iban->storedBic());
- } catch (payeeIdentifier::exception&) {
+ } catch (const payeeIdentifier::empty &) {
+ } catch (const payeeIdentifier::badCast &) {
}
}
@@ -412,7 +416,8 @@
try {
payeeIdentifier ident = getOnlineJobTyped().task()->originAccountIdentifier();
payeeIban = ident.data()->electronicIban();
- } catch (payeeIdentifier::exception&) {
+ } catch (const payeeIdentifier::empty &) {
+ } catch (const payeeIdentifier::badCast &) {
}
if (settings->isBicMandatory(payeeIban, iban)) {
@@ -433,7 +438,7 @@
QString iban;
try {
iban = payee.data()->electronicIban();
- } catch (payeeIdentifier::badCast&) {
+ } catch (const payeeIdentifier::badCast &) {
}
if (settings->isBicMandatory(iban , ui->beneficiaryIban->text())) {
diff --git a/kmymoney/plugins/qif/config/mymoneyqifprofile.cpp b/kmymoney/plugins/qif/config/mymoneyqifprofile.cpp
--- a/kmymoney/plugins/qif/config/mymoneyqifprofile.cpp
+++ b/kmymoney/plugins/qif/config/mymoneyqifprofile.cpp
@@ -426,7 +426,7 @@
}
break;
} else {
- throw MYMONEYEXCEPTION("Invalid char in QifProfile date field");
+ throw MYMONEYEXCEPTION(QStringLiteral("Invalid char in QifProfile date field"));
}
delim = 0;
} else {
diff --git a/kmymoney/plugins/qif/export/mymoneyqifwriter.cpp b/kmymoney/plugins/qif/export/mymoneyqifwriter.cpp
--- a/kmymoney/plugins/qif/export/mymoneyqifwriter.cpp
+++ b/kmymoney/plugins/qif/export/mymoneyqifwriter.cpp
@@ -80,10 +80,7 @@
emit signalProgress(-1, -1);
} catch (const MyMoneyException &e) {
- QString errMsg = i18n("Unexpected exception '%1' thrown in %2, line %3 "
- "caught in MyMoneyQifWriter::write()", e.what(), e.file(), e.line());
-
- KMessageBox::error(0, errMsg);
+ KMessageBox::error(nullptr, i18n("Unexpected exception '%1'", e.what()));
}
qifFile.close();
diff --git a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
--- a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
+++ b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
@@ -648,7 +648,7 @@
break;
}
} catch (const MyMoneyException &e) {
- if (e.what() != "USERABORT") {
+ if (e.what().contains("USERABORT")) {
qDebug() << "Line " << m_linenumber << ": Unhandled error: " << e.what();
} else {
m_userAbort = true;
@@ -1008,9 +1008,9 @@
// remember which account we created
d->st.m_accountId = m_account.id();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedError(0,
+ KMessageBox::detailedError(nullptr,
i18n("Error while creating opening balance transaction"),
- QString("%1(%2):%3").arg(e.file()).arg(e.line()).arg(e.what()),
+ e.what(),
i18n("File access error"));
}
}
@@ -1101,7 +1101,7 @@
break;
case KMessageBox::Cancel:
- throw MYMONEYEXCEPTION("USERABORT");
+ throw MYMONEYEXCEPTION(QStringLiteral("USERABORT"));
break;
}
}
@@ -1329,7 +1329,7 @@
break;
case KMessageBox::Cancel:
- throw MYMONEYEXCEPTION("USERABORT");
+ throw MYMONEYEXCEPTION(QStringLiteral("USERABORT"));
break;
}
}
diff --git a/kmymoney/plugins/sql/mymoneydbdef.cpp b/kmymoney/plugins/sql/mymoneydbdef.cpp
--- a/kmymoney/plugins/sql/mymoneydbdef.cpp
+++ b/kmymoney/plugins/sql/mymoneydbdef.cpp
@@ -688,7 +688,7 @@
{
QHash::ConstIterator i = m_fieldOrder.find(name);
if (m_fieldOrder.constEnd() == i) {
- throw MYMONEYEXCEPTION(QString("Unknown field %1 in table %2").arg(name).arg(m_name));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Unknown field %1 in table %2").arg(name).arg(m_name));
}
return i.value();
}
diff --git a/kmymoney/plugins/sql/mymoneydbdriver.cpp b/kmymoney/plugins/sql/mymoneydbdriver.cpp
--- a/kmymoney/plugins/sql/mymoneydbdriver.cpp
+++ b/kmymoney/plugins/sql/mymoneydbdriver.cpp
@@ -176,7 +176,7 @@
return QExplicitlySharedDataPointer (new MyMoneySqlite3Driver());
else if (type == "SQLCIPHER")
return QExplicitlySharedDataPointer (new MyMoneySqlCipher3Driver());
- else throw MYMONEYEXCEPTION(QString("Unknown database driver type").arg(type));
+ else throw MYMONEYEXCEPTION(QStringLiteral("Unknown database driver type."));
}
MyMoneyDbDriver::MyMoneyDbDriver()
@@ -691,7 +691,7 @@
case QSql::AllTables:
selectString = QString("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '%1'").arg(db.databaseName());
if (!q.exec(selectString)) {
- throw MYMONEYEXCEPTION("select names failed in mymoneydbdriver.cpp");
+ throw MYMONEYEXCEPTION(QStringLiteral("select names failed in mymoneydbdriver.cpp"));
}
while (q.next())
tableList.append(q.value(0).toString());
diff --git a/kmymoney/plugins/sql/mymoneystoragesql.cpp b/kmymoney/plugins/sql/mymoneystoragesql.cpp
--- a/kmymoney/plugins/sql/mymoneystoragesql.cpp
+++ b/kmymoney/plugins/sql/mymoneystoragesql.cpp
@@ -45,7 +45,7 @@
{
try {
close(true);
- } catch (const MyMoneyException& e) {
+ } catch (const MyMoneyException &e) {
qDebug() << "Caught Exception in MMStorageSql dtor: " << e.what();
}
Q_D(MyMoneyStorageSql);
@@ -279,7 +279,7 @@
{
Q_D(MyMoneyStorageSql);
if (d->m_commitUnitStack.isEmpty()) {
- if (!transaction()) throw MYMONEYEXCEPTION(d->buildError(QSqlQuery(), callingFunction, "starting commit unit") + ' ' + callingFunction);
+ if (!transaction()) throw MYMONEYEXCEPTION(d->buildError(QSqlQuery(), callingFunction, "starting commit unit"));
}
d->m_commitUnitStack.push(callingFunction);
}
@@ -294,7 +294,7 @@
// as value of this method.
bool rc = true;
if (d->m_commitUnitStack.isEmpty()) {
- throw MYMONEYEXCEPTION("Empty commit unit stack while trying to commit");
+ throw MYMONEYEXCEPTION(QStringLiteral("Empty commit unit stack while trying to commit"));
}
if (callingFunction != d->m_commitUnitStack.top())
@@ -366,10 +366,10 @@
QVariantList kvpList;
kvpList << inst.id();
d->deleteKeyValuePairs("OFXSETTINGS", kvpList);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmInstitutions"].deleteString());
- q.bindValue(":id", inst.id());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Institution"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmInstitutions"].deleteString());
+ query.bindValue(":id", inst.id());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Institution")); // krazy:exclude=crashy
--d->m_institutions;
d->writeFileInfo();
}
@@ -378,9 +378,9 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmPayees"].insertString());
- d->writePayee(payee, q);
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmPayees"].insertString());
+ d->writePayee(payee, query);
++d->m_payees;
QVariantList identIds;
@@ -392,7 +392,7 @@
// note: this changes ident
addPayeeIdentifier(ident);
identIds.append(ident.idString());
- } catch (payeeIdentifier::empty&) {
+ } catch (const payeeIdentifier::empty &) {
}
}
@@ -407,12 +407,12 @@
order << i;
payeeIdList << payee.id();
}
- q.prepare("INSERT INTO kmmPayeesPayeeIdentifier (payeeId, identifierId, userOrder) VALUES(?, ?, ?)");
- q.bindValue(0, payeeIdList);
- q.bindValue(1, identIds);
- q.bindValue(2, order);
- if (!q.execBatch())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("writing payee's identifiers"))); // krazy:exclude=crashy
+ query.prepare("INSERT INTO kmmPayeesPayeeIdentifier (payeeId, identifierId, userOrder) VALUES(?, ?, ?)");
+ query.bindValue(0, payeeIdList);
+ query.bindValue(1, identIds);
+ query.bindValue(2, order);
+ if (!query.execBatch())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing payee's identifiers")); // krazy:exclude=crashy
}
d->writeFileInfo();
@@ -422,20 +422,20 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmPayees"].updateString());
- d->writePayee(payee, q);
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmPayees"].updateString());
+ d->writePayee(payee, query);
// Get a list of old identifiers first
- q.prepare("SELECT identifierId FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?");
- q.bindValue(0, payee.id());
- if (!q.exec())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("modifying payee's identifiers (getting old values failed)"))); // krazy:exclude=crashy
+ query.prepare("SELECT identifierId FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?");
+ query.bindValue(0, payee.id());
+ if (!query.exec())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("modifying payee's identifiers (getting old values failed)")); // krazy:exclude=crashy
QStringList oldIdentIds;
- oldIdentIds.reserve(q.numRowsAffected());
- while (q.next())
- oldIdentIds << q.value(0).toString();
+ oldIdentIds.reserve(query.numRowsAffected());
+ while (query.next())
+ oldIdentIds << query.value(0).toString();
// Add new and modify old payeeIdentifiers
foreach (payeeIdentifier ident, payee.payeeIdentifiers()) {
@@ -460,10 +460,10 @@
}
// Update relation table
- q.prepare("DELETE FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?");
- q.bindValue(0, payee.id());
- if (!q.exec())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("modifying payee's identifiers (delete from mapping table)"))); // krazy:exclude=crashy
+ query.prepare("DELETE FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?");
+ query.bindValue(0, payee.id());
+ if (!query.exec())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("modifying payee's identifiers (delete from mapping table)")); // krazy:exclude=crashy
// Get list again because modifiyPayeeIdentifier which is used above may change the id
QList idents(payee.payeeIdentifiers());
@@ -485,12 +485,12 @@
}
}
- q.prepare("INSERT INTO kmmPayeesPayeeIdentifier (payeeId, userOrder, identifierId) VALUES(?, ?, ?)");
- q.bindValue(0, payeeIdList);
- q.bindValue(1, order);
- q.bindValue(2, identIdList);
- if (!q.execBatch())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("writing payee's identifiers during modify"))); // krazy:exclude=crashy
+ query.prepare("INSERT INTO kmmPayeesPayeeIdentifier (payeeId, userOrder, identifierId) VALUES(?, ?, ?)");
+ query.bindValue(0, payeeIdList);
+ query.bindValue(1, order);
+ query.bindValue(2, identIdList);
+ if (!query.execBatch())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing payee's identifiers during modify")); // krazy:exclude=crashy
d->writeFileInfo();
}
@@ -509,17 +509,17 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
+ QSqlQuery query(*this);
// Get identifiers first so we know which to delete
- q.prepare("SELECT identifierId FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?");
- q.bindValue(0, payee.id());
- if (!q.exec())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("removing payee's identifiers (getting old values failed)"))); // krazy:exclude=crashy
+ query.prepare("SELECT identifierId FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?");
+ query.bindValue(0, payee.id());
+ if (!query.exec())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("removing payee's identifiers (getting old values failed)")); // krazy:exclude=crashy
QStringList identIds;
- while (q.next())
- identIds << q.value(0).toString();
+ while (query.next())
+ identIds << query.value(0).toString();
QMap idents = fetchPayeeIdentifiers(identIds);
foreach (payeeIdentifier ident, idents) {
@@ -527,15 +527,15 @@
}
// Delete entries from mapping table
- q.prepare("DELETE FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?");
- q.bindValue(0, payee.id());
- if (!q.exec())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("removing payee's identifiers (delete from mapping table)"))); // krazy:exclude=crashy
+ query.prepare("DELETE FROM kmmPayeesPayeeIdentifier WHERE payeeId = ?");
+ query.bindValue(0, payee.id());
+ if (!query.exec())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("removing payee's identifiers (delete from mapping table)")); // krazy:exclude=crashy
// Delete payee
- q.prepare(d->m_db.m_tables["kmmPayees"].deleteString());
- q.bindValue(":id", payee.id());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Payee"))); // krazy:exclude=crashy
+ query.prepare(d->m_db.m_tables["kmmPayees"].deleteString());
+ query.bindValue(":id", payee.id());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Payee")); // krazy:exclude=crashy
--d->m_payees;
d->writeFileInfo();
@@ -567,10 +567,10 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmTags"].deleteString());
- q.bindValue(":id", tag.id());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Tag"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmTags"].deleteString());
+ query.bindValue(":id", tag.id());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Tag")); // krazy:exclude=crashy
--d->m_tags;
d->writeFileInfo();
}
@@ -620,10 +620,10 @@
kvpList << acc.id();
d->deleteKeyValuePairs("ACCOUNT", kvpList);
d->deleteKeyValuePairs("ONLINEBANKING", kvpList);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmAccounts"].deleteString());
- q.bindValue(":id", acc.id());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Account"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmAccounts"].deleteString());
+ query.bindValue(":id", acc.id());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Account")); // krazy:exclude=crashy
--d->m_accounts;
d->writeFileInfo();
}
@@ -656,17 +656,17 @@
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
// remove the splits of the old tx from the count table
- QSqlQuery q(*this);
- q.prepare("SELECT accountId FROM kmmSplits WHERE transactionId = :txId;");
- q.bindValue(":txId", tx.id());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, "retrieving old splits"));
- while (q.next()) {
- QString id = q.value(0).toString();
+ QSqlQuery query(*this);
+ query.prepare("SELECT accountId FROM kmmSplits WHERE transactionId = :txId;");
+ query.bindValue(":txId", tx.id());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("retrieving old splits"));
+ while (query.next()) {
+ QString id = query.value(0).toString();
--d->m_transactionCountMap[id];
}
// add the transaction and splits
- q.prepare(d->m_db.m_tables["kmmTransactions"].updateString());
- d->writeTransaction(tx.id(), tx, q, "N");
+ query.prepare(d->m_db.m_tables["kmmTransactions"].updateString());
+ d->writeTransaction(tx.id(), tx, query, "N");
QList aList;
// for each split account, update lastMod date, balance, txCount
foreach (const MyMoneySplit& it_s, tx.splits()) {
@@ -763,10 +763,10 @@
QVariantList kvpList;
kvpList << sec.id();
d->deleteKeyValuePairs("SECURITY", kvpList);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmSecurities"].deleteString());
- q.bindValue(":id", kvpList);
- if (!q.execBatch()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Security")));
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmSecurities"].deleteString());
+ query.bindValue(":id", kvpList);
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Security"));
--d->m_securities;
d->writeFileInfo();
}
@@ -779,30 +779,30 @@
// the app always calls addPrice, whether or not there is already one there
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
bool newRecord = false;
- QSqlQuery q(*this);
+ QSqlQuery query(*this);
QString s = d->m_db.m_tables["kmmPrices"].selectAllString(false);
s += " WHERE fromId = :fromId AND toId = :toId AND priceDate = :priceDate;";
- q.prepare(s);
- q.bindValue(":fromId", p.from());
- q.bindValue(":toId", p.to());
- q.bindValue(":priceDate", p.date().toString(Qt::ISODate));
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("finding Price"))); // krazy:exclude=crashy
- if (q.next()) {
- q.prepare(d->m_db.m_tables["kmmPrices"].updateString());
+ query.prepare(s);
+ query.bindValue(":fromId", p.from());
+ query.bindValue(":toId", p.to());
+ query.bindValue(":priceDate", p.date().toString(Qt::ISODate));
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("finding Price")); // krazy:exclude=crashy
+ if (query.next()) {
+ query.prepare(d->m_db.m_tables["kmmPrices"].updateString());
} else {
- q.prepare(d->m_db.m_tables["kmmPrices"].insertString());
+ query.prepare(d->m_db.m_tables["kmmPrices"].insertString());
++d->m_prices;
newRecord = true;
}
- q.bindValue(":fromId", p.from());
- q.bindValue(":toId", p.to());
- q.bindValue(":priceDate", p.date().toString(Qt::ISODate));
- q.bindValue(":price", p.rate(QString()).toString());
+ query.bindValue(":fromId", p.from());
+ query.bindValue(":toId", p.to());
+ query.bindValue(":priceDate", p.date().toString(Qt::ISODate));
+ query.bindValue(":price", p.rate(QString()).toString());
const MyMoneySecurity sec = d->m_storage->security(p.to());
- q.bindValue(":priceFormatted",
+ query.bindValue(":priceFormatted",
p.rate(QString()).formatMoney("", sec.pricePrecision()));
- q.bindValue(":priceSource", p.source());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("writing Price"))); // krazy:exclude=crashy
+ query.bindValue(":priceSource", p.source());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing Price")); // krazy:exclude=crashy
if (newRecord) d->writeFileInfo();
}
@@ -811,12 +811,12 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmPrices"].deleteString());
- q.bindValue(":fromId", p.from());
- q.bindValue(":toId", p.to());
- q.bindValue(":priceDate", p.date().toString(Qt::ISODate));
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Price"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmPrices"].deleteString());
+ query.bindValue(":fromId", p.from());
+ query.bindValue(":toId", p.to());
+ query.bindValue(":priceDate", p.date().toString(Qt::ISODate));
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Price")); // krazy:exclude=crashy
--d->m_prices;
d->writeFileInfo();
}
@@ -847,10 +847,10 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmCurrencies"].deleteString());
- q.bindValue(":ISOcode", sec.id());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Currency"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmCurrencies"].deleteString());
+ query.bindValue(":ISOcode", sec.id());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Currency")); // krazy:exclude=crashy
--d->m_currencies;
d->writeFileInfo();
}
@@ -880,10 +880,10 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare("DELETE FROM kmmReportConfig WHERE id = :id");
- q.bindValue(":id", rep.id());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Report"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare("DELETE FROM kmmReportConfig WHERE id = :id");
+ query.bindValue(":id", rep.id());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Report")); // krazy:exclude=crashy
--d->m_reports;
d->writeFileInfo();
}
@@ -913,10 +913,10 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmBudgetConfig"].deleteString());
- q.bindValue(":id", bud.id());
- if (!q.exec()) throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting Budget"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmBudgetConfig"].deleteString());
+ query.bindValue(":id", bud.id());
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting Budget")); // krazy:exclude=crashy
--d->m_budgets;
d->writeFileInfo();
}
@@ -925,11 +925,11 @@
{
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare("INSERT INTO kmmOnlineJobs (id, type, jobSend, bankAnswerDate, state, locked) VALUES(:id, :type, :jobSend, :bankAnswerDate, :state, :locked);");
- d->writeOnlineJob(job, q);
- if (!q.exec())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("writing onlineJob"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare("INSERT INTO kmmOnlineJobs (id, type, jobSend, bankAnswerDate, state, locked) VALUES(:id, :type, :jobSend, :bankAnswerDate, :state, :locked);");
+ d->writeOnlineJob(job, query);
+ if (!query.exec())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing onlineJob")); // krazy:exclude=crashy
++d->m_onlineJobs;
try {
@@ -958,7 +958,7 @@
d->writeOnlineJob(job, query);
if (!query.exec())
- throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("writing onlineJob"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("writing onlineJob")); // krazy:exclude=crashy
try {
// Modify online task
@@ -982,11 +982,11 @@
} catch (onlineJob::emptyTask&) {
}
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmOnlineJobs"].deleteString());
- q.bindValue(":id", job.id());
- if (!q.exec())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting onlineJob"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmOnlineJobs"].deleteString());
+ query.bindValue(":id", job.id());
+ if (!query.exec())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting onlineJob")); // krazy:exclude=crashy
--d->m_onlineJobs;
}
@@ -1004,7 +1004,7 @@
try {
d->insertStorableObject(*ident.data(), ident.idString());
- } catch (payeeIdentifier::empty&) {
+ } catch (const payeeIdentifier::empty &) {
}
}
@@ -1013,38 +1013,38 @@
Q_D(MyMoneyStorageSql);
MyMoneyDbTransaction t(*this, Q_FUNC_INFO);
- QSqlQuery q(*this);
- q.prepare("SELECT type FROM kmmPayeeIdentifier WHERE id = ?");
- q.bindValue(0, ident.idString());
- if (!q.exec() || !q.next())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("modifying payeeIdentifier"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare("SELECT type FROM kmmPayeeIdentifier WHERE id = ?");
+ query.bindValue(0, ident.idString());
+ if (!query.exec() || !query.next())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("modifying payeeIdentifier")); // krazy:exclude=crashy
- bool typeChanged = (q.value(0).toString() != ident.iid());
+ bool typeChanged = (query.value(0).toString() != ident.iid());
if (typeChanged) {
// Delete old identifier if type changed
const payeeIdentifier oldIdent(fetchPayeeIdentifier(ident.idString()));
try {
d->deleteStorableObject(*oldIdent.data(), ident.idString());
- } catch (payeeIdentifier::empty&) {
+ } catch (const payeeIdentifier::empty &) {
// Note: this should not happen because the ui does not offer a way to change
// the type of an payeeIdentifier if it was not correctly loaded.
- throw MYMONEYEXCEPTION(QLatin1String("Could not modify payeeIdentifier '")
+ throw MYMONEYEXCEPTION((QString::fromLatin1("Could not modify payeeIdentifier '")
+ ident.idString()
- + QLatin1String("' because type changed and could not remove identifier of old type. Maybe a plugin is missing?")
+ + QLatin1String("' because type changed and could not remove identifier of old type. Maybe a plugin is missing?"))
); // krazy:exclude=crashy
}
}
- q.prepare("UPDATE kmmPayeeIdentifier SET type = :type WHERE id = :id");
- d->writePayeeIdentifier(ident, q);
+ query.prepare("UPDATE kmmPayeeIdentifier SET type = :type WHERE id = :id");
+ d->writePayeeIdentifier(ident, query);
try {
if (typeChanged)
d->insertStorableObject(*ident.data(), ident.idString());
else
d->updateStorableObject(*ident.data(), ident.idString());
- } catch (payeeIdentifier::empty&) {
+ } catch (const payeeIdentifier::empty &) {
}
}
@@ -1057,14 +1057,14 @@
// of row in kmmPayeeIdentifier
try {
d->deleteStorableObject(*ident.data(), ident.idString());
- } catch (payeeIdentifier::empty&) {
+ } catch (const payeeIdentifier::empty &) {
}
- QSqlQuery q(*this);
- q.prepare(d->m_db.m_tables["kmmPayeeIdentifier"].deleteString());
- q.bindValue(":id", ident.idString());
- if (!q.exec())
- throw MYMONEYEXCEPTION(d->buildError(q, Q_FUNC_INFO, QString("deleting payeeIdentifier"))); // krazy:exclude=crashy
+ QSqlQuery query(*this);
+ query.prepare(d->m_db.m_tables["kmmPayeeIdentifier"].deleteString());
+ query.bindValue(":id", ident.idString());
+ if (!query.exec())
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("deleting payeeIdentifier")); // krazy:exclude=crashy
--d->m_payeeIdentifier;
}
@@ -1120,7 +1120,7 @@
}
}
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Institution"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString::fromLatin1("reading Institution"))); // krazy:exclude=crashy
int idCol = t.fieldNumber("id");
int nameCol = t.fieldNumber("name");
int managerCol = t.fieldNumber("manager");
@@ -1142,7 +1142,7 @@
inst.setTelephone(GETSTRING(telephoneCol));
// get list of subaccounts
sq.bindValue(":id", iid);
- if (!sq.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Institution AccountList"))); // krazy:exclude=crashy
+ if (!sq.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Institution AccountList")); // krazy:exclude=crashy
QStringList aList;
while (sq.next()) aList.append(sq.value(0).toString());
foreach (const QString& it, aList)
@@ -1231,7 +1231,7 @@
}
if (!query.exec())
- throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Payee"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString::fromLatin1("reading Payee"))); // krazy:exclude=crashy
const QSqlRecord record = query.record();
const int idCol = record.indexOf("id");
const int nameCol = record.indexOf("name");
@@ -1349,7 +1349,7 @@
}
}
if (!query.exec())
- throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading onlineJobs"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading onlineJobs")); // krazy:exclude=crashy
// Create onlineJobs
int progress = 0;
@@ -1392,7 +1392,7 @@
QMap list = fetchPayeeIdentifiers(QStringList(id));
QMap::const_iterator iter = list.constFind(id);
if (iter == list.constEnd())
- throw MYMONEYEXCEPTION(QLatin1String("payeeIdentifier with id '") + id + QLatin1String("' not found.")); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTION(QString::fromLatin1("payeeIdentifier with id '%1' not found").arg(id)); // krazy:exclude=crashy
return *iter;
}
@@ -1415,7 +1415,7 @@
}
}
if (!query.exec())
- throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading payee identifiers"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading payee identifiers")); // krazy:exclude=crashy
QMap identList;
@@ -1459,7 +1459,7 @@
whereClause += ')';
query.prepare(t.selectAllString(false) + whereClause);
}
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Tag"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Tag")); // krazy:exclude=crashy
int idCol = t.fieldNumber("id");
int nameCol = t.fieldNumber("name");
int notesCol = t.fieldNumber("notes");
@@ -1538,8 +1538,8 @@
}
}
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Account"))); // krazy:exclude=crashy
- if (!sq.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading subAccountList"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Account")); // krazy:exclude=crashy
+ if (!sq.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading subAccountList")); // krazy:exclude=crashy
// Reserve enough space for all values. Approximate it with the size of the
// idList in case the db doesn't support reporting the size of the
@@ -1666,7 +1666,7 @@
}
if (!query.exec()) // krazy:exclude=crashy
- throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("fetching balance")));
+ throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("fetching balance"));
QString id;
QString oldId;
MyMoneyMoney temp;
@@ -1721,7 +1721,7 @@
const MyMoneyDbTable& t = d->m_db.m_tables["kmmTransactions"];
QSqlQuery query(*const_cast (this));
query.prepare(t.selectAllString(false) + whereClause + " ORDER BY id;");
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Transaction"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Transaction")); // krazy:exclude=crashy
const MyMoneyDbTable& ts = d->m_db.m_tables["kmmSplits"];
whereClause = " WHERE txType = 'N' ";
if (! tidList.isEmpty()) {
@@ -2078,7 +2078,7 @@
}
}
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Schedules"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Schedules")); // krazy:exclude=crashy
int idCol = t.fieldNumber("id");
int nameCol = t.fieldNumber("name");
int typeCol = t.fieldNumber("type");
@@ -2164,7 +2164,7 @@
// read in the recorded payments
sq.bindValue(":id", s.id());
- if (!sq.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading schedule payment history"))); // krazy:exclude=crashy
+ if (!sq.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading schedule payment history")); // krazy:exclude=crashy
while (sq.next()) s.recordPayment(sq.value(0).toDate());
sList[s.id()] = s;
@@ -2196,7 +2196,7 @@
const MyMoneyDbTable& t = d->m_db.m_tables["kmmSecurities"];
QSqlQuery query(*const_cast (this));
query.prepare(t.selectAllString(false) + " ORDER BY id;");
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Securities"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Securities")); // krazy:exclude=crashy
int idCol = t.fieldNumber("id");
int nameCol = t.fieldNumber("name");
int symbolCol = t.fieldNumber("symbol");
@@ -2351,7 +2351,7 @@
}
}
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Prices"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Prices")); // krazy:exclude=crashy
static const int fromIdCol = t.fieldNumber("fromId");
static const int toIdCol = t.fieldNumber("toId");
static const int priceDateCol = t.fieldNumber("priceDate");
@@ -2413,7 +2413,7 @@
}
}
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading Currencies"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading Currencies")); // krazy:exclude=crashy
int ISOcodeCol = t.fieldNumber("ISOcode");
int nameCol = t.fieldNumber("name");
int typeCol = t.fieldNumber("type");
@@ -2459,7 +2459,7 @@
const MyMoneyDbTable& t = d->m_db.m_tables["kmmReportConfig"];
QSqlQuery query(*const_cast (this));
query.prepare(t.selectAllString(true));
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading reports"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading reports")); // krazy:exclude=crashy
int xmlCol = t.fieldNumber("XML");
QMap rList;
while (query.next()) {
@@ -2501,7 +2501,7 @@
queryString += ';';
query.prepare(queryString);
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading budgets"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading budgets")); // krazy:exclude=crashy
QMap budgets;
int xmlCol = t.fieldNumber("XML");
while (query.next()) {
@@ -2816,7 +2816,7 @@
whereClause += ')';
query.prepare(t.selectAllString(false) + whereClause);
}
- if (!query.exec()) throw MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, QString("reading CostCenter"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL_D(QString::fromLatin1("reading CostCenter")); // krazy:exclude=crashy
const int idCol = t.fieldNumber("id");
const int nameCol = t.fieldNumber("name");
diff --git a/kmymoney/plugins/sql/mymoneystoragesql_p.h b/kmymoney/plugins/sql/mymoneystoragesql_p.h
--- a/kmymoney/plugins/sql/mymoneystoragesql_p.h
+++ b/kmymoney/plugins/sql/mymoneystoragesql_p.h
@@ -123,10 +123,10 @@
} else {
try{
m_db.endCommitUnit(m_name);
- } catch(MyMoneyException&) {
+ } catch (const MyMoneyException &) {
try {
m_db.cancelCommitUnit(m_name);
- } catch (const MyMoneyException & e) {
+ } catch (const MyMoneyException &e) {
qDebug() << e.what();
}
}
@@ -184,6 +184,8 @@
#define GETDATETIME(a) getDateTime(GETSTRING(a))
#define GETINT(a) query.value(a).toInt()
#define GETULL(a) query.value(a).toULongLong()
+#define MYMONEYEXCEPTIONSQL(exceptionMessage) MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, exceptionMessage))
+#define MYMONEYEXCEPTIONSQL_D(exceptionMessage) MYMONEYEXCEPTION(d->buildError(query, Q_FUNC_INFO, exceptionMessage))
class MyMoneyStorageSqlPrivate
{
@@ -248,7 +250,7 @@
QSqlQuery query(*q);
if (!query.exec(m_driver->highestNumberFromIdString(tableName, tableField, prefixLength)) || !query.next())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("retrieving highest ID number"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("retrieving highest ID number");
return query.value(0).toULongLong();
}
@@ -275,7 +277,7 @@
QList dbList;
QSqlQuery query(*q);
query.prepare("SELECT id FROM kmmInstitutions;");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Institution list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building Institution list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toString());
const QList list = m_storage->institutionList();
@@ -308,7 +310,7 @@
}
query.prepare("DELETE FROM kmmInstitutions WHERE id = :id");
query.bindValue(":id", deleteList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Institution"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Institution");
deleteKeyValuePairs("OFXSETTINGS", deleteList);
}
@@ -322,7 +324,7 @@
QSqlQuery query(*q);
query.prepare("SELECT id FROM kmmPayees;");
if (!query.exec())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Payee list")); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("building Payee list"); // krazy:exclude=crashy
QList dbList;
dbList.reserve(query.numRowsAffected());
@@ -359,7 +361,7 @@
QList dbList;
QSqlQuery query(*q);
query.prepare("SELECT id FROM kmmTags;");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Tag list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building Tag list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toString());
QList list = m_storage->tagList();
@@ -385,7 +387,7 @@
}
query.prepare(m_db.m_tables["kmmTags"].deleteString());
query.bindValue(":id", deleteList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Tag"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Tag");
m_tags -= query.numRowsAffected();
}
}
@@ -397,7 +399,7 @@
QList dbList;
QSqlQuery query(*q);
query.prepare("SELECT id FROM kmmAccounts;");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Account list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building Account list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toString());
QList list;
@@ -489,7 +491,7 @@
}
}
query.bindValue(":id", kvpList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Account"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Account");
deleteKeyValuePairs("ACCOUNT", kvpList);
deleteKeyValuePairs("ONLINEBANKING", kvpList);
@@ -503,7 +505,7 @@
QList dbList;
QSqlQuery query(*q);
query.prepare("SELECT id FROM kmmTransactions WHERE txType = 'N';");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Transaction list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building Transaction list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toString());
MyMoneyTransactionFilter filter;
@@ -538,7 +540,7 @@
QList dbList;
QSqlQuery query(*q);
query.prepare("SELECT id FROM kmmSchedules;");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Schedule list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building Schedule list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toString());
const auto list = m_storage->scheduleList(QString(), Schedule::Type::Any, Schedule::Occurrence::Any, Schedule::PaymentType::Any,
@@ -576,7 +578,7 @@
QSqlQuery query(*q);
QSqlQuery query2(*q);
query.prepare("SELECT id FROM kmmSecurities;");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building security list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building security list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toString());
const QList securityList = m_storage->securityList();
@@ -603,11 +605,11 @@
query.prepare("DELETE FROM kmmSecurities WHERE id = :id");
query2.prepare("DELETE FROM kmmPrices WHERE fromId = :id OR toId = :id");
query.bindValue(":id", idList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Security"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Security");
query2.bindValue(":fromId", idList);
query2.bindValue(":toId", idList);
- if (!query2.execBatch()) throw MYMONEYEXCEPTION(buildError(query2, Q_FUNC_INFO, "deleting Security"));
+ if (!query2.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Security");
deleteKeyValuePairs("SECURITY", idList);
}
@@ -620,7 +622,7 @@
// easiest way is to delete all and re-insert
QSqlQuery query(*q);
query.prepare("DELETE FROM kmmPrices");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("deleting Prices"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("deleting Prices"); // krazy:exclude=crashy
m_prices = 0;
const MyMoneyPriceList list = m_storage->priceList();
@@ -639,7 +641,7 @@
QSqlQuery query(*q);
QSqlQuery query2(*q);
query.prepare("SELECT ISOCode FROM kmmCurrencies;");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Currency list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building Currency list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toString());
const QList currencyList = m_storage->currencyList();
@@ -665,7 +667,7 @@
}
query.bindValue(":ISOCode", isoCodeList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Currency"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Currency");
}
}
@@ -683,12 +685,12 @@
QSqlQuery query(*q);
query.prepare("SELECT count(*) FROM kmmFileInfo;");
if (!query.exec() || !query.next())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "checking fileinfo")); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("checking fileinfo"); // krazy:exclude=crashy
if (query.value(0).toInt() == 0) {
// Cannot use "INSERT INTO kmmFileInfo DEFAULT VALUES;" because it is not supported by MySQL
query.prepare(QLatin1String("INSERT INTO kmmFileInfo (version) VALUES (null);"));
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "inserting fileinfo")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("inserting fileinfo"); // krazy:exclude=crashy
}
query.prepare(QLatin1String(
@@ -790,7 +792,7 @@
query.bindValue(":budgets", (unsigned long long) m_budgets);
if (!query.exec())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing FileInfo"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("writing FileInfo"); // krazy:exclude=crashy
}
void writeReports()
@@ -801,7 +803,7 @@
QSqlQuery query(*q);
QSqlQuery query2(*q);
query.prepare("SELECT id FROM kmmReportConfig;");
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Report list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building Report list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toString());
QList list = m_storage->reportList();
@@ -827,7 +829,7 @@
}
query.bindValue(":id", idList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Report"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Report");
}
}
@@ -840,7 +842,7 @@
QSqlQuery query2(*q);
query.prepare("SELECT name FROM kmmBudgetConfig;");
if (!query.exec())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Budget list")); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("building Budget list"); // krazy:exclude=crashy
while (query.next())
dbList.append(query.value(0).toString());
@@ -868,7 +870,7 @@
query.bindValue(":name", idList);
if (!query.execBatch())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Budget"));
+ throw MYMONEYEXCEPTIONSQL("deleting Budget");
}
}
@@ -877,7 +879,7 @@
Q_Q(MyMoneyStorageSql);
QSqlQuery query(*q);
if (!query.exec("DELETE FROM kmmOnlineJobs;"))
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QLatin1String("Clean kmmOnlineJobs table")));
+ throw MYMONEYEXCEPTIONSQL("Clean kmmOnlineJobs table");
const QList jobs(m_storage->onlineJobList());
signalProgress(0, jobs.count(), i18n("Inserting online jobs."));
@@ -887,7 +889,7 @@
foreach (const onlineJob& job, jobs) {
try {
q->addOnlineJob(job);
- } catch (MyMoneyException& e) {
+ } catch (const MyMoneyException &e) {
// Do not save e as this may point to an inherited class
failedJobs.append(QPair(job, e.what()));
qDebug() << "Failed to save onlineJob" << job.id() << "Reson:" << e.what();
@@ -898,7 +900,7 @@
if (!failedJobs.isEmpty()) {
/** @todo Improve error message */
- throw MYMONEYEXCEPTION(i18np("Could not save one onlineJob.", "Could not save %1 onlineJobs.", failedJobs.count()));
+ throw MYMONEYEXCEPTION(QStringLiteral("Could not save onlineJob."));
}
}
/** @} */
@@ -943,7 +945,7 @@
query.bindValue(":telephone", telephoneList);
if (!query.execBatch())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Institution")));
+ throw MYMONEYEXCEPTIONSQL("writing Institution");
writeKeyValuePairs("OFXSETTINGS", idList, kvpPairsList);
// Set m_hiIdInstitutions to 0 to force recalculation the next time it is requested
m_hiIdInstitutions = 0;
@@ -978,7 +980,7 @@
query.bindValue(":matchKeys", matchKeys);
if (!query.exec()) // krazy:exclude=crashy
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Payee"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("writing Payee"); // krazy:exclude=crashy
if (!isUserInfo)
m_hiIdPayees = 0;
@@ -992,7 +994,7 @@
if (ta.isClosed()) query.bindValue(":closed", "Y");
else query.bindValue(":closed", "N");
query.bindValue(":notes", ta.notes());
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Tag"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Tag"); // krazy:exclude=crashy
m_hiIdTags = 0;
}
@@ -1083,7 +1085,7 @@
query.bindValue(":transactionCount", transactionCountList);
if (!query.execBatch())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Account")));
+ throw MYMONEYEXCEPTIONSQL("writing Account");
//Add in Key-Value Pairs for accounts.
writeKeyValuePairs("ACCOUNT", idList, pairs);
@@ -1102,7 +1104,7 @@
query.bindValue(":bankId", tx.bankID());
if (!query.exec()) // krazy:exclude=crashy
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Transaction"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("writing Transaction"); // krazy:exclude=crashy
m_txPostDate = tx.postDate(); // FIXME: TEMP till Tom puts date in split object
QList splitList = tx.splits();
@@ -1130,7 +1132,7 @@
QSqlQuery query(*q);
query.prepare("SELECT splitId FROM kmmSplits where transactionId = :id;");
query.bindValue(":id", txId);
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "building Split list")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("building Split list"); // krazy:exclude=crashy
while (query.next()) dbList.append(query.value(0).toUInt());
QSqlQuery query2(*q);
@@ -1171,7 +1173,7 @@
}
query.bindValue(":txId", txIdList.toList());
query.bindValue(":splitId", splitIdList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Splits"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Splits");
}
}
@@ -1201,7 +1203,7 @@
query.bindValue(":tagId", tagIdList);
query.bindValue(":splitId", splitIdList_TagSplits);
query.bindValue(":transactionId", txIdList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing tagSplits")));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("writing tagSplits");
}
void writeSplitList
@@ -1298,7 +1300,7 @@
query.bindValue(":checkNumber", checkNumberList);
query.bindValue(":postDate", postDateList);
query.bindValue(":bankId", bankIdList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Split")));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("writing Split");
deleteKeyValuePairs("SPLIT", kvpIdList);
writeKeyValuePairs("SPLIT", kvpIdList, kvpPairsList);
}
@@ -1335,19 +1337,19 @@
query.bindValue(":nextPaymentDue", sch.nextDueDate().toString(Qt::ISODate));
query.bindValue(":weekendOption", (int)sch.weekendOption());
query.bindValue(":weekendOptionString", MyMoneySchedule::weekendOptionToString(sch.weekendOption()));
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Schedules"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Schedules"); // krazy:exclude=crashy
//store the payment history for this scheduled task.
//easiest way is to delete all and re-insert; it's not a high use table
query.prepare("DELETE FROM kmmSchedulePaymentHistory WHERE schedId = :id;");
query.bindValue(":id", sch.id());
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("deleting Schedule Payment History"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("deleting Schedule Payment History"); // krazy:exclude=crashy
query.prepare(m_db.m_tables["kmmSchedulePaymentHistory"].insertString());
foreach (const QDate& it, sch.recordedPayments()) {
query.bindValue(":schedId", sch.id());
query.bindValue(":payDate", it.toString(Qt::ISODate));
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Schedule Payment History"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Schedule Payment History"); // krazy:exclude=crashy
}
//store the transaction data for this task.
@@ -1377,7 +1379,7 @@
query.bindValue(":pricePrecision", security.pricePrecision());
query.bindValue(":tradingCurrency", security.tradingCurrency());
query.bindValue(":tradingMarket", security.tradingMarket());
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Securities"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Securities"); // krazy:exclude=crashy
//Add in Key-Value Pairs for security
QVariantList idList;
@@ -1408,7 +1410,7 @@
query.bindValue(":price", p.rate(QString()).toString());
query.bindValue(":priceFormatted", p.rate(QString()).formatMoney("", 2));
query.bindValue(":priceSource", p.source());
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Prices"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Prices"); // krazy:exclude=crashy
}
void writeCurrency(const MyMoneySecurity& currency, QSqlQuery& query)
@@ -1433,7 +1435,7 @@
query.bindValue(":smallestCashFraction", currency.smallestCashFraction());
query.bindValue(":smallestAccountFraction", currency.smallestAccountFraction());
query.bindValue(":pricePrecision", currency.pricePrecision());
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Currencies"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Currencies"); // krazy:exclude=crashy
}
void writeReport(const MyMoneyReport& rep, QSqlQuery& query)
@@ -1445,7 +1447,7 @@
query.bindValue(":id", rep.id());
query.bindValue(":name", rep.name());
query.bindValue(":XML", d.toString());
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Reports"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("writing Reports"); // krazy:exclude=crashy
}
void writeBudget(const MyMoneyBudget& bud, QSqlQuery& query)
@@ -1459,7 +1461,7 @@
query.bindValue(":start", bud.budgetStart());
query.bindValue(":XML", d.toString());
if (!query.exec()) // krazy:exclude=crashy
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing Budgets"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("writing Budgets"); // krazy:exclude=crashy
}
void writeKeyValuePairs(const QString& kvpType, const QVariantList& kvpId, const QList >& pairs)
@@ -1491,7 +1493,7 @@
query.bindValue(":kvpId", id);
query.bindValue(":kvpKey", key);
query.bindValue(":kvpData", value);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("writing KVP")));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("writing KVP");
m_kvps += pairCount;
}
@@ -1520,7 +1522,7 @@
query.bindValue(":type", pid.iid());
if (!query.exec()) { // krazy:exclude=crashy
qWarning() << buildError(query, Q_FUNC_INFO, QString("modifying payeeIdentifier"));
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("modifying payeeIdentifier"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("modifying payeeIdentifier"); // krazy:exclude=crashy
}
}
/** @} */
@@ -1560,9 +1562,9 @@
);
if (!query.exec())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("reading FileInfo"))); // krazy:exclude=crashy
+ throw MYMONEYEXCEPTIONSQL("reading FileInfo"); // krazy:exclude=crashy
if (!query.next())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("retrieving FileInfo")));
+ throw MYMONEYEXCEPTIONSQL("retrieving FileInfo");
QSqlRecord rec = query.record();
m_storage->setCreationDate(GETDATE(rec.indexOf("created")));
@@ -1657,7 +1659,7 @@
query1.prepare("SELECT tagId from kmmTagSplits where splitId = :id and transactionId = :transactionId");
query1.bindValue(":id", GETSTRING(splitIdCol));
query1.bindValue(":transactionId", GETSTRING(transactionIdCol));
- if (!query1.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("reading tagId in Split"))); // krazy:exclude=crashy
+ if (!query1.exec()) throw MYMONEYEXCEPTIONSQL("reading tagId in Split"); // krazy:exclude=crashy
while (query1.next())
tagIdList << query1.value(0).toString();
@@ -1687,8 +1689,8 @@
query.prepare("SELECT kvpKey, kvpData from kmmKeyValuePairs where kvpType = :type and kvpId = :id;");
query.bindValue(":type", kvpType);
query.bindValue(":id", kvpId);
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("reading Kvp for %1 %2").arg(kvpType) // krazy:exclude=crashy
- .arg(kvpId)));
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL(QString::fromLatin1("reading Kvp for %1 %2").arg(kvpType) // krazy:exclude=crashy
+ .arg(kvpId));
while (query.next()) list.setValue(query.value(0).toString(), query.value(1).toString());
return (list);
}
@@ -1709,7 +1711,7 @@
query.prepare(sQuery);
query.bindValue(":type", kvpType);
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("reading Kvp List for %1").arg(kvpType))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL(QString::fromLatin1("reading Kvp List for %1").arg(kvpType)); // krazy:exclude=crashy
// Reserve enough space for all values.
retval.reserve(kvpIdList.size());
@@ -1807,19 +1809,19 @@
idList << id;
query.prepare("DELETE FROM kmmSplits WHERE transactionId = :transactionId;");
query.bindValue(":transactionId", idList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Splits"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Splits");
query.prepare("DELETE FROM kmmKeyValuePairs WHERE kvpType = 'SPLIT' "
"AND kvpId LIKE '?%'");
query.bindValue(1, idList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Splits KVP"));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting Splits KVP");
m_splits -= query.numRowsAffected();
deleteKeyValuePairs("TRANSACTION", idList);
query.prepare(m_db.m_tables["kmmTransactions"].deleteString());
query.bindValue(":id", idList);
if (!query.execBatch())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Transaction"));
+ throw MYMONEYEXCEPTIONSQL("deleting Transaction");
}
void deleteTagSplitsList(const QString& txId, const QList& splitIdList)
@@ -1838,7 +1840,7 @@
query.prepare("DELETE FROM kmmTagSplits WHERE transactionId = :transactionId AND splitId = :splitId");
query.bindValue(":splitId", iList);
query.bindValue(":transactionId", transactionIdList);
- if (!query.execBatch()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("deleting tagSplits")));
+ if (!query.execBatch()) throw MYMONEYEXCEPTIONSQL("deleting tagSplits");
}
void deleteSchedule(const QString& id)
@@ -1848,10 +1850,10 @@
QSqlQuery query(*q);
query.prepare("DELETE FROM kmmSchedulePaymentHistory WHERE schedId = :id");
query.bindValue(":id", id);
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Schedule Payment History")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("deleting Schedule Payment History"); // krazy:exclude=crashy
query.prepare(m_db.m_tables["kmmSchedules"].deleteString());
query.bindValue(":id", id);
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "deleting Schedule")); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("deleting Schedule"); // krazy:exclude=crashy
//FIXME: enable when schedules have KVPs.
//deleteKeyValuePairs("SCHEDULE", id);
}
@@ -1872,7 +1874,7 @@
for (int i = 0; i < idList.size(); ++i) {
idString.append(idList[i].toString() + ' ');
}
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("deleting kvp for %1 %2").arg(kvpType).arg(idString)));
+ throw MYMONEYEXCEPTIONSQL(QString::fromLatin1("deleting kvp for %1 %2").arg(kvpType).arg(idString));
}
m_kvps -= query.numRowsAffected();
}
@@ -1990,8 +1992,8 @@
maindb.setUserName(url.userName());
maindb.setPassword(url.password());
if (!maindb.open()) {
- throw MYMONEYEXCEPTION(QString("opening database %1 in function %2")
- .arg(maindb.databaseName()).arg(Q_FUNC_INFO));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("opening database %1 in function %2")
+ .arg(maindb.databaseName()).arg(Q_FUNC_INFO));
} else {
QSqlQuery qm(maindb);
QString qs = m_driver->createDbString(dbName) + ';';
@@ -2063,7 +2065,7 @@
for (QMap::ConstIterator tt = m_db.viewBegin(); tt != m_db.viewEnd(); ++tt) {
if (lowerTables.contains(tt.key().toLower())) {
if (!query.exec("DROP VIEW " + tt.value().name() + ';')) // krazy:exclude=crashy
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("dropping view %1").arg(tt.key())));
+ throw MYMONEYEXCEPTIONSQL(QString::fromLatin1("dropping view %1").arg(tt.key()));
}
}
@@ -2131,8 +2133,7 @@
for (QMap::ConstIterator tt = m_db.viewBegin(); tt != m_db.viewEnd(); ++tt) {
if (!lowerTables.contains(tt.key().toLower())) {
if (!query.exec(tt.value().createString())) // krazy:exclude=crashy
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO,
- QString("creating view %1").arg(tt.key())));
+ throw MYMONEYEXCEPTIONSQL(QString::fromLatin1("creating view %1").arg(tt.key()));
}
}
@@ -2502,7 +2503,7 @@
QSqlQuery query(*q);
for (QMap::ConstIterator tt = m_db.viewBegin(); tt != m_db.viewEnd(); ++tt) {
if (!lowerTables.contains(tt.key().toLower())) {
- if (!query.exec(tt.value().createString())) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("creating view %1").arg(tt.key())));
+ if (!query.exec(tt.value().createString())) throw MYMONEYEXCEPTIONSQL(QString::fromLatin1("creating view %1").arg(tt.key()));
}
}
@@ -2514,7 +2515,7 @@
query.bindValue(0, m_dbVersion);
query.bindValue(1, m_storage->fileFixVersion());
if (!query.exec())
- throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("Saving database version")));
+ throw MYMONEYEXCEPTIONSQL(QString::fromLatin1("Saving database version"));
}
return upgradeDb();
@@ -2527,7 +2528,7 @@
QStringList ql = t.generateCreateSQL(m_driver, version).split('\n', QString::SkipEmptyParts);
QSqlQuery query(*q);
foreach (const QString& i, ql) {
- if (!query.exec(i)) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("creating table/index %1").arg(t.name())));
+ if (!query.exec(i)) throw MYMONEYEXCEPTIONSQL(QString::fromLatin1("creating table/index %1").arg(t.name()));
}
}
@@ -2584,7 +2585,7 @@
QSqlQuery query(*q);
while (it != m_db.tableEnd()) {
query.prepare(QString("DELETE from %1;").arg(it.key()));
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, QString("cleaning database"))); // krazy:exclude=crashy
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("cleaning database"); // krazy:exclude=crashy
++it;
}
}
@@ -2598,8 +2599,8 @@
QSqlQuery query(*q);
while ((tt != m_db.tableEnd()) && (recordCount == 0)) {
query.prepare(QString("select count(*) from %1;").arg((*tt).name()));
- if (!query.exec()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "getting record count")); // krazy:exclude=crashy
- if (!query.next()) throw MYMONEYEXCEPTION(buildError(query, Q_FUNC_INFO, "retrieving record count"));
+ if (!query.exec()) throw MYMONEYEXCEPTIONSQL("getting record count"); // krazy:exclude=crashy
+ if (!query.next()) throw MYMONEYEXCEPTIONSQL("retrieving record count");
recordCount += query.value(0).toInt();
++tt;
}
@@ -2658,7 +2659,7 @@
);
if (plugin == 0)
- throw MYMONEYEXCEPTION(QString("Could not load sqlStoragePlugin '%1', (error: %2)").arg(iid, errorMsg));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Could not load sqlStoragePlugin '%1', (error: %2)").arg(iid, errorMsg));
MyMoneyDbTransaction t(*q, Q_FUNC_INFO);
if (plugin->setupDatabase(*q)) {
@@ -2666,7 +2667,7 @@
return true;
}
- throw MYMONEYEXCEPTION(QString("Could not install sqlStoragePlugin '%1' in database.").arg(iid));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Could not install sqlStoragePlugin '%1' in database.").arg(iid));
}
void insertStorableObject(const databaseStoreableObject& obj, const QString& id)
@@ -2674,7 +2675,7 @@
Q_Q(MyMoneyStorageSql);
setupStoragePlugin(obj.storagePluginIid());
if (!obj.sqlSave(*q, id))
- throw MYMONEYEXCEPTION(QString("Could not save object with id '%1' in database (plugin failed).").arg(id));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Could not save object with id '%1' in database (plugin failed).").arg(id));
}
void updateStorableObject(const databaseStoreableObject& obj, const QString& id)
@@ -2682,7 +2683,7 @@
Q_Q(MyMoneyStorageSql);
setupStoragePlugin(obj.storagePluginIid());
if (!obj.sqlModify(*q, id))
- throw MYMONEYEXCEPTION(QString("Could not modify object with id '%1' in database (plugin failed).").arg(id));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Could not modify object with id '%1' in database (plugin failed).").arg(id));
}
void deleteStorableObject(const databaseStoreableObject& obj, const QString& id)
@@ -2690,7 +2691,7 @@
Q_Q(MyMoneyStorageSql);
setupStoragePlugin(obj.storagePluginIid());
if (!obj.sqlRemove(*q, id))
- throw MYMONEYEXCEPTION(QString("Could not remove object with id '%1' from database (plugin failed).").arg(id));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Could not remove object with id '%1' from database (plugin failed).").arg(id));
}
void alert(QString s) const // FIXME: remove...
diff --git a/kmymoney/plugins/views/budget/kbudgetview.cpp b/kmymoney/plugins/views/budget/kbudgetview.cpp
--- a/kmymoney/plugins/views/budget/kbudgetview.cpp
+++ b/kmymoney/plugins/views/budget/kbudgetview.cpp
@@ -131,7 +131,7 @@
MyMoneyFile::instance()->addBudget(budget);
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Error"), i18n("Unable to add budget: %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to add budget"), e.what());
}
}
@@ -160,7 +160,7 @@
file->removeBudget(budget);
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Error"), i18n("Unable to remove budget: %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to remove budget."), e.what());
}
}
@@ -177,7 +177,7 @@
MyMoneyFile::instance()->addBudget(budget);
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Error"), i18n("Unable to add budget: %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to add budget"), e.what());
}
}
}
@@ -214,7 +214,7 @@
MyMoneyFile::instance()->modifyBudget(budget);
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Error"), i18n("Unable to modify budget: %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify budget."), e.what());
}
}
}
@@ -252,7 +252,7 @@
ft.commit();
}
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Error"), i18n("Unable to modify budget: %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify budget."), e.what());
}
}
}
@@ -272,8 +272,7 @@
}
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Unable to reset budget"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to reset budget"), e.what());
}
}
@@ -286,8 +285,7 @@
ft.commit();
d->refreshHideUnusedButton();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Unable to modify budget"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify budget"), e.what());
}
}
@@ -380,8 +378,7 @@
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Unable to modify budget"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify budget"), e.what());
}
} else {
pBudget->setText(0, new_name);
diff --git a/kmymoney/plugins/views/onlinejoboutbox/konlinejoboutboxview.cpp b/kmymoney/plugins/views/onlinejoboutbox/konlinejoboutboxview.cpp
--- a/kmymoney/plugins/views/onlinejoboutbox/konlinejoboutboxview.cpp
+++ b/kmymoney/plugins/views/onlinejoboutbox/konlinejoboutboxview.cpp
@@ -119,7 +119,7 @@
try {
const onlineJob constJob = MyMoneyFile::instance()->getOnlineJob(jobId);
editJob(constJob);
- } catch (MyMoneyException&) {
+ } catch (const MyMoneyException &) {
// Prevent a crash in very rare cases
}
}
@@ -128,7 +128,7 @@
{
try {
editJob(onlineJobTyped(job));
- } catch (MyMoneyException&) {
+ } catch (const MyMoneyException &) {
}
}
diff --git a/kmymoney/plugins/views/onlinejoboutbox/konlinetransferform.cpp b/kmymoney/plugins/views/onlinejoboutbox/konlinetransferform.cpp
--- a/kmymoney/plugins/views/onlinejoboutbox/konlinetransferform.cpp
+++ b/kmymoney/plugins/views/onlinejoboutbox/konlinetransferform.cpp
@@ -127,7 +127,7 @@
if (showWidget)
showEditWidget(widget);
- } catch (MyMoneyException&) {
+ } catch (const MyMoneyException &) {
qWarning("Error while loading a plugin (IonlineJobEdit).");
}
}
@@ -219,7 +219,7 @@
const QString accountId = ui->originAccount->getSelected();
try {
ui->orderAccountBalance->setValue(MyMoneyFile::instance()->balance(accountId));
- } catch (const MyMoneyException&) {
+ } catch (const MyMoneyException &) {
// @todo this can happen until the selection allows to select correct accounts only
ui->orderAccountBalance->setText("");
}
diff --git a/kmymoney/plugins/views/onlinejoboutbox/onlinejobmodel.cpp b/kmymoney/plugins/views/onlinejoboutbox/onlinejobmodel.cpp
--- a/kmymoney/plugins/views/onlinejoboutbox/onlinejobmodel.cpp
+++ b/kmymoney/plugins/views/onlinejoboutbox/onlinejobmodel.cpp
@@ -113,7 +113,7 @@
try {
job = MyMoneyFile::instance()->getOnlineJob(m_jobIdList[index.row()]);
- } catch (const MyMoneyException&) {
+ } catch (const MyMoneyException &) {
return QVariant();
}
@@ -196,8 +196,7 @@
return QVariant(ibanBic->ownerName());
}
}
- } catch (MyMoneyException&) {
- } catch (payeeIdentifier::exception&) {
+ } catch (const MyMoneyException &) {
}
return QVariant();
diff --git a/kmymoney/plugins/views/reports/kreportconfigurationfilterdlg.cpp b/kmymoney/plugins/views/reports/kreportconfigurationfilterdlg.cpp
--- a/kmymoney/plugins/views/reports/kreportconfigurationfilterdlg.cpp
+++ b/kmymoney/plugins/views/reports/kreportconfigurationfilterdlg.cpp
@@ -501,7 +501,7 @@
combo->setCurrentItem(i18n("Week"), false);
break;
default:
- throw MYMONEYEXCEPTION("KReportConfigurationFilterDlg::slotReset(): QueryTable report has invalid rowtype");
+ throw MYMONEYEXCEPTION(QStringLiteral("KReportConfigurationFilterDlg::slotReset(): QueryTable report has invalid rowtype"));
}
unsigned qc = d->m_initialState.queryColumns();
@@ -543,7 +543,7 @@
combo->setCurrentItem(d->m_initialState.chartType());
break;
default:
- throw MYMONEYEXCEPTION("KReportConfigurationFilterDlg::slotReset(): Report has invalid charttype");
+ throw MYMONEYEXCEPTION(QStringLiteral("KReportConfigurationFilterDlg::slotReset(): Report has invalid charttype"));
}
d->m_tabChart->ui->m_checkCHGridLines->setChecked(d->m_initialState.isChartCHGridLines());
d->m_tabChart->ui->m_checkSVGridLines->setChecked(d->m_initialState.isChartSVGridLines());
diff --git a/kmymoney/reports/objectinfotable.cpp b/kmymoney/reports/objectinfotable.cpp
--- a/kmymoney/reports/objectinfotable.cpp
+++ b/kmymoney/reports/objectinfotable.cpp
@@ -112,7 +112,7 @@
m_subtotal << ctCurrentBalance;
break;
default:
- throw MYMONEYEXCEPTION("ObjectInfoTable::ObjectInfoTable(): unhandled row type");
+ throw MYMONEYEXCEPTION(QStringLiteral("ObjectInfoTable::ObjectInfoTable(): unhandled row type"));
}
QVector sort = QVector::fromList(m_group) << QVector::fromList(m_columns) << ctID << ctRank;
diff --git a/kmymoney/reports/pivottable.cpp b/kmymoney/reports/pivottable.cpp
--- a/kmymoney/reports/pivottable.cpp
+++ b/kmymoney/reports/pivottable.cpp
@@ -194,8 +194,8 @@
try {
transactions = file->transactionList(m_config);
} catch (const MyMoneyException &e) {
- qDebug("ERR: %s thrown in %s(%ld)", qPrintable(e.what()), qPrintable(e.file()), e.line());
- throw e;
+ qDebug("ERR: %s", qPrintable(e.what()));
+ throw;
}
DEBUG_OUTPUT(QString("Found %1 matching transactions").arg(transactions.count()));
@@ -480,9 +480,9 @@
PivotInnerGroup::iterator it_row = (*it_innergroup).begin();
while (it_row != (*it_innergroup).end()) {
if ((*it_row)[eActual].count() <= sourcecolumn)
- throw MYMONEYEXCEPTION(QString("Sourcecolumn %1 out of grid range (%2) in PivotTable::accumulateColumn").arg(sourcecolumn).arg((*it_row)[eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Sourcecolumn %1 out of grid range (%2) in PivotTable::accumulateColumn").arg(sourcecolumn).arg((*it_row)[eActual].count()));
if ((*it_row)[eActual].count() <= destcolumn)
- throw MYMONEYEXCEPTION(QString("Destcolumn %1 out of grid range (%2) in PivotTable::accumulateColumn").arg(sourcecolumn).arg((*it_row)[eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Destcolumn %1 out of grid range (%2) in PivotTable::accumulateColumn").arg(sourcecolumn).arg((*it_row)[eActual].count()));
(*it_row)[eActual][destcolumn] += (*it_row)[eActual][sourcecolumn];
++it_row;
@@ -509,7 +509,7 @@
PivotInnerGroup::iterator it_row = (*it_innergroup).begin();
while (it_row != (*it_innergroup).end()) {
if ((*it_row)[eActual].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::accumulateColumn").arg(column).arg((*it_row)[eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::accumulateColumn").arg(column).arg((*it_row)[eActual].count()));
(*it_row++)[eActual][column] = PivotCell();
}
@@ -694,7 +694,7 @@
int column = m_startColumn;
while (column < m_numColumns) {
if (it_row.value()[eActual].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateRunningSums").arg(column).arg(it_row.value()[eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::calculateRunningSums").arg(column).arg(it_row.value()[eActual].count()));
runningsum = it_row.value()[eActual][column].calculateRunningSum(runningsum);
@@ -719,7 +719,7 @@
int column = m_startColumn;
while (column < m_numColumns) {
if (it_row.value()[eActual].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateRunningSums").arg(column).arg(it_row.value()[eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::calculateRunningSums").arg(column).arg(it_row.value()[eActual].count()));
runningsum = (it_row.value()[eActual][column] += runningsum);
@@ -739,7 +739,7 @@
{
if (m_runningSumsCalculated) {
qDebug("You must not call PivotTable::cellBalance() after calling PivotTable::calculateRunningSums()");
- throw MYMONEYEXCEPTION(QString("You must not call PivotTable::cellBalance() after calling PivotTable::calculateRunningSums()"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("You must not call PivotTable::cellBalance() after calling PivotTable::calculateRunningSums()"));
}
// for budget reports, if this is the actual value, map it to the account which
@@ -763,9 +763,9 @@
QString innergroup(row.topParentName());
if (m_numColumns <= _column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of m_numColumns range (%2) in PivotTable::cellBalance").arg(_column).arg(m_numColumns));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of m_numColumns range (%2) in PivotTable::cellBalance").arg(_column).arg(m_numColumns));
if (m_grid[outergroup][innergroup][row][eActual].count() <= _column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::cellBalance").arg(_column).arg(m_grid[outergroup][innergroup][row][eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::cellBalance").arg(_column).arg(m_grid[outergroup][innergroup][row][eActual].count()));
MyMoneyMoney balance;
if (budget)
@@ -776,7 +776,7 @@
int column = m_startColumn;
while (column < _column) {
if (m_grid[outergroup][innergroup][row][eActual].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::cellBalance").arg(column).arg(m_grid[outergroup][innergroup][row][eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::cellBalance").arg(column).arg(m_grid[outergroup][innergroup][row][eActual].count()));
balance = m_grid[outergroup][innergroup][row][eActual][column].cellBalance(balance);
@@ -996,7 +996,7 @@
auto column = 0;
while (column < m_numColumns) {
if (it_row.value()[eActual].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::convertToBaseCurrency").arg(column).arg(it_row.value()[eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::convertToBaseCurrency").arg(column).arg(it_row.value()[eActual].count()));
QDate valuedate = columnDate(column);
@@ -1045,7 +1045,7 @@
auto column = 0;
while (column < m_numColumns) {
if (it_row.value()[eActual].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::convertToDeepCurrency").arg(column).arg(it_row.value()[eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::convertToDeepCurrency").arg(column).arg(it_row.value()[eActual].count()));
QDate valuedate = columnDate(column);
@@ -1130,9 +1130,9 @@
while (column < m_numColumns) {
for (int i = 0; i < m_rowTypeList.size(); ++i) {
if (it_row.value()[ m_rowTypeList[i] ].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateTotals, row columns").arg(column).arg(it_row.value()[ m_rowTypeList[i] ].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::calculateTotals, row columns").arg(column).arg(it_row.value()[ m_rowTypeList[i] ].count()));
if ((*it_innergroup).m_total[ m_rowTypeList[i] ].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateTotals, inner group totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::calculateTotals, inner group totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count()));
//calculate total
MyMoneyMoney value = it_row.value()[ m_rowTypeList[i] ][column];
@@ -1152,9 +1152,9 @@
while (column < m_numColumns) {
for (int i = 0; i < m_rowTypeList.size(); ++i) {
if ((*it_innergroup).m_total[ m_rowTypeList[i] ].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateTotals, inner group totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::calculateTotals, inner group totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count()));
if ((*it_outergroup).m_total[ m_rowTypeList[i] ].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateTotals, outer group totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::calculateTotals, outer group totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count()));
//calculate totals
MyMoneyMoney value = (*it_innergroup).m_total[ m_rowTypeList[i] ][column];
@@ -1177,7 +1177,7 @@
while (column < m_numColumns) {
for (int i = 0; i < m_rowTypeList.size(); ++i) {
if (m_grid.m_total[ m_rowTypeList[i] ].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::calculateTotals, grid totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::calculateTotals, grid totals").arg(column).arg((*it_innergroup).m_total[ m_rowTypeList[i] ].count()));
//calculate actual totals
MyMoneyMoney value = (*it_outergroup).m_total[ m_rowTypeList[i] ][column];
@@ -1205,7 +1205,7 @@
while (totalcolumn < m_numColumns) {
for (int i = 0; i < m_rowTypeList.size(); ++i) {
if (m_grid.m_total[ m_rowTypeList[i] ].count() <= totalcolumn)
- throw MYMONEYEXCEPTION(QString("Total column %1 out of grid range (%2) in PivotTable::calculateTotals, grid totals").arg(totalcolumn).arg(m_grid.m_total[ m_rowTypeList[i] ].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Total column %1 out of grid range (%2) in PivotTable::calculateTotals, grid totals").arg(totalcolumn).arg(m_grid.m_total[ m_rowTypeList[i] ].count()));
//calculate actual totals
MyMoneyMoney value = m_grid.m_total[ m_rowTypeList[i] ][totalcolumn];
@@ -1241,11 +1241,11 @@
QString innergroup(row.topParentName());
if (m_numColumns <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of m_numColumns range (%2) in PivotTable::assignCell").arg(column).arg(m_numColumns));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of m_numColumns range (%2) in PivotTable::assignCell").arg(column).arg(m_numColumns));
if (m_grid[outergroup][innergroup][row][eActual].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::assignCell").arg(column).arg(m_grid[outergroup][innergroup][row][eActual].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::assignCell").arg(column).arg(m_grid[outergroup][innergroup][row][eActual].count()));
if (m_grid[outergroup][innergroup][row][eBudget].count() <= column)
- throw MYMONEYEXCEPTION(QString("Column %1 out of grid range (%2) in PivotTable::assignCell").arg(column).arg(m_grid[outergroup][innergroup][row][eBudget].count()));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("Column %1 out of grid range (%2) in PivotTable::assignCell").arg(column).arg(m_grid[outergroup][innergroup][row][eBudget].count()));
if (!stockSplit) {
// Determine whether the value should be inverted before being placed in the row
diff --git a/kmymoney/reports/querytable.cpp b/kmymoney/reports/querytable.cpp
--- a/kmymoney/reports/querytable.cpp
+++ b/kmymoney/reports/querytable.cpp
@@ -345,7 +345,7 @@
m_group << ctInstitution << ctTopAccount;
break;
default:
- throw MYMONEYEXCEPTION("QueryTable::QueryTable(): unhandled row type");
+ throw MYMONEYEXCEPTION(QStringLiteral("QueryTable::QueryTable(): unhandled row type"));
}
QVector sort = QVector::fromList(m_group) << QVector::fromList(m_columns) << ctID << ctRank;
diff --git a/kmymoney/reports/tests/reportstestcommon.cpp b/kmymoney/reports/tests/reportstestcommon.cpp
--- a/kmymoney/reports/tests/reportstestcommon.cpp
+++ b/kmymoney/reports/tests/reportstestcommon.cpp
@@ -139,7 +139,7 @@
try {
MyMoneyFile::instance()->removeTransaction(*this);
ft.commit();
- } catch (const MyMoneyException & e) {
+ } catch (const MyMoneyException &e) {
qDebug() << e.what();
}
}
@@ -475,7 +475,7 @@
if (readRCFfromXMLDoc(list, doc) && !list.isEmpty())
filter = list[0];
else
- throw MYMONEYEXCEPTION("Failed to load report from XML");
+ throw MYMONEYEXCEPTION(QStringLiteral("Failed to load report from XML"));
delete doc;
diff --git a/kmymoney/views/kgloballedgerview.cpp b/kmymoney/views/kgloballedgerview.cpp
--- a/kmymoney/views/kgloballedgerview.cpp
+++ b/kmymoney/views/kgloballedgerview.cpp
@@ -1504,7 +1504,7 @@
if (!d->m_currentAccount.id().isEmpty())
slotLedgerSelected(d->m_currentAccount.id(), lt.id());
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Error"), i18n("Unable to duplicate transaction(s): %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to duplicate transaction(s)"), e.what());
}
// switch off the progress bar
emit selectByVariant(QVariantList {QVariant(-1), QVariant(-1)}, eView::Intent::ReportProgress);
@@ -1579,7 +1579,7 @@
emit selectByVariant(QVariantList {QVariant(-1), QVariant(-1)}, eView::Intent::ReportProgress);
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Error"), i18n("Unable to accept transaction: %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to accept transaction"), e.what());
}
}
@@ -1620,7 +1620,7 @@
d->m_transactionEditor->enterTransactions(id);
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Error"), i18n("Unable to modify transaction: %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("nable to modify transaction"), e.what());
}
}
}
diff --git a/kmymoney/views/kgloballedgerview_p.h b/kmymoney/views/kgloballedgerview_p.h
--- a/kmymoney/views/kgloballedgerview_p.h
+++ b/kmymoney/views/kgloballedgerview_p.h
@@ -1215,7 +1215,7 @@
}
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(q, i18n("Error"), i18n("Unable to delete transaction(s): %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(q, i18n("Unable to delete transaction(s)"), e.what());
}
emit q->slotStatusProgress(-1, -1);
}
@@ -1294,9 +1294,9 @@
MyMoneyFileTransaction ft;
try {
if (startMatchTransaction.id().isEmpty())
- throw MYMONEYEXCEPTION(i18n("No manually entered transaction selected for matching"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("No manually entered transaction selected for matching"));
if (endMatchTransaction.id().isEmpty())
- throw MYMONEYEXCEPTION(i18n("No imported transaction selected for matching"));
+ throw MYMONEYEXCEPTION(QString::fromLatin1("No imported transaction selected for matching"));
TransactionMatcher matcher(m_currentAccount);
matcher.match(startMatchTransaction, startSplit, endMatchTransaction, endSplit, true);
@@ -1377,7 +1377,7 @@
emit q->slotStatusProgress(-1, -1);
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(q, i18n("Error"), i18n("Unable to modify transaction: %1, thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(q, i18n("Unable to modify transaction"), e.what());
}
}
diff --git a/kmymoney/views/kmymoneyview.cpp b/kmymoney/views/kmymoneyview.cpp
--- a/kmymoney/views/kmymoneyview.cpp
+++ b/kmymoney/views/kmymoneyview.cpp
@@ -625,7 +625,7 @@
// We assume at least 2 splits in the transaction
MyMoneyTransaction t = newSchedule.transaction();
if (t.splitCount() < 2) {
- throw MYMONEYEXCEPTION("Transaction for schedule has less than 2 splits!");
+ throw MYMONEYEXCEPTION(QStringLiteral("Transaction for schedule has less than 2 splits!"));
}
// now search the split that does not have an account reference
// and set it up to be the one of the account we just added
diff --git a/kmymoney/views/kpayeesview.cpp b/kmymoney/views/kpayeesview.cpp
--- a/kmymoney/views/kpayeesview.cpp
+++ b/kmymoney/views/kpayeesview.cpp
@@ -208,8 +208,7 @@
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Unable to modify payee"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify payee"), e.what());
}
} else {
p->setText(new_name);
@@ -319,7 +318,7 @@
d->showTransactions();
} catch (const MyMoneyException &e) {
- qDebug("exception during display of payee: %s at %s:%ld", qPrintable(e.what()), qPrintable(e.file()), e.line());
+ qDebug("exception during display of payee: %s", qPrintable(e.what()));
d->ui->m_register->clear();
d->m_selectedPayeesList.clear();
d->m_payee = MyMoneyPayee();
@@ -433,8 +432,7 @@
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(0, i18n("Unable to modify payee"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify payee"), e.what());
}
}
}
@@ -500,8 +498,7 @@
MyMoneyFile::instance()->modifyPayee(d->m_payee);
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(0, i18n("Unable to modify payee"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify payee"), e.what());
}
}
diff --git a/kmymoney/views/kpayeesview_p.h b/kmymoney/views/kpayeesview_p.h
--- a/kmymoney/views/kpayeesview_p.h
+++ b/kmymoney/views/kpayeesview_p.h
@@ -605,8 +605,7 @@
}
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(q, i18n("Unable to reassign payee of transaction/split"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(q, i18n("Unable to reassign payee of transaction/split"), e.what());
}
} else { // if !translist.isEmpty()
if (type == KPayeeReassignDlg::TypeMerge) {
@@ -668,8 +667,7 @@
m_selectedPayeesList.clear();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(q, i18n("Unable to remove payee(s)"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(q, i18n("Unable to remove payee(s)"), e.what());
}
return true;
diff --git a/kmymoney/views/ktagsview.cpp b/kmymoney/views/ktagsview.cpp
--- a/kmymoney/views/ktagsview.cpp
+++ b/kmymoney/views/ktagsview.cpp
@@ -158,8 +158,7 @@
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Unable to modify tag"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify tag"), e.what());
}
} else {
ta->setText(new_name);
@@ -265,7 +264,7 @@
showTransactions();
} catch (const MyMoneyException &e) {
- qDebug("exception during display of tag: %s at %s:%ld", qPrintable(e.what()), qPrintable(e.file()), e.line());
+ qDebug("exception during display of tag: %s", qPrintable(e.what()));
d->ui->m_register->clear();
d->m_tag = MyMoneyTag();
}
@@ -393,8 +392,7 @@
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Unable to modify tag"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to modify tag"), e.what());
}
}
}
@@ -735,8 +733,7 @@
} // for - Schedules
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Unable to reassign tag of transaction/split"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to reassign tag of transaction/split"), e.what());
}
} // if !translist.isEmpty()
@@ -752,7 +749,6 @@
slotSelectTags(QList());
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(this, i18n("Unable to remove tag(s)"),
- i18n("%1 thrown in %2:%3", e.what(), e.file(), e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to remove tag(s)"), e.what());
}
}
diff --git a/kmymoney/wizards/newaccountwizard/kloandetailspage.cpp b/kmymoney/wizards/newaccountwizard/kloandetailspage.cpp
--- a/kmymoney/wizards/newaccountwizard/kloandetailspage.cpp
+++ b/kmymoney/wizards/newaccountwizard/kloandetailspage.cpp
@@ -230,7 +230,7 @@
// calculate the number of payments out of the other information
val = calc.numPayments();
if (val == 0)
- throw MYMONEYEXCEPTION("incorrect fincancial calculation");
+ throw MYMONEYEXCEPTION(QStringLiteral("incorrect fincancial calculation"));
// if the number of payments has a fractional part, then we
// round it to the smallest integer and calculate the balloon payment
@@ -262,7 +262,7 @@
|| (moneyLend && val > 0 && qAbs(val) > qAbs(calc.payment()))) {
// case a)
qDebug("Future Value is %f", val);
- throw MYMONEYEXCEPTION("incorrect fincancial calculation");
+ throw MYMONEYEXCEPTION(QStringLiteral("incorrect fincancial calculation"));
} else if ((moneyBorrowed && val < 0 && qAbs(val) <= qAbs(calc.payment()))
|| (moneyLend && val > 0 && qAbs(val) <= qAbs(calc.payment()))) {
@@ -275,7 +275,7 @@
if (!d->ui->m_balloonAmount->lineedit()->text().isEmpty()) {
if ((d->ui->m_balloonAmount->value().abs() - refVal.abs()).abs().toDouble() > 1) {
- throw MYMONEYEXCEPTION("incorrect fincancial calculation");
+ throw MYMONEYEXCEPTION(QStringLiteral("incorrect fincancial calculation"));
}
result = i18n("KMyMoney has successfully verified your loan information.");
}
diff --git a/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp b/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp
--- a/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp
+++ b/kmymoney/wizards/newinvestmentwizard/knewinvestmentwizard.cpp
@@ -276,7 +276,7 @@
}
ft.commit();
} catch (const MyMoneyException &e) {
- KMessageBox::detailedSorry(0, i18n("Unable to create all objects for the investment"), QString("%1 caugt in %2:%3").arg(e.what()).arg(e.file()).arg(e.line()));
+ KMessageBox::detailedSorry(this, i18n("Unable to create all objects for the investment"), e.what());
}
}
diff --git a/kmymoney/wizards/newloanwizard/interestcategorywizardpage.cpp b/kmymoney/wizards/newloanwizard/interestcategorywizardpage.cpp
--- a/kmymoney/wizards/newloanwizard/interestcategorywizardpage.cpp
+++ b/kmymoney/wizards/newloanwizard/interestcategorywizardpage.cpp
@@ -100,7 +100,7 @@
QString id;
id = file->createCategory(base, acc.name());
if (id.isEmpty())
- throw MYMONEYEXCEPTION("failure while creating the account hierarchy");
+ throw MYMONEYEXCEPTION(QStringLiteral("failure while creating the account hierarchy"));
ft.commit();
diff --git a/kmymoney/wizards/newloanwizard/keditloanwizard.cpp b/kmymoney/wizards/newloanwizard/keditloanwizard.cpp
--- a/kmymoney/wizards/newloanwizard/keditloanwizard.cpp
+++ b/kmymoney/wizards/newloanwizard/keditloanwizard.cpp
@@ -415,7 +415,7 @@
split = (*it).splitByAccount(m_account.id());
balance += split.value();
- } catch(const MyMoneyException &e) {
+ } catch (const MyMoneyException &e) {
// account is not referenced within this transaction
}
}
diff --git a/kmymoney/wizards/newloanwizard/knewloanwizard_p.h b/kmymoney/wizards/newloanwizard/knewloanwizard_p.h
--- a/kmymoney/wizards/newloanwizard/knewloanwizard_p.h
+++ b/kmymoney/wizards/newloanwizard/knewloanwizard_p.h
@@ -356,7 +356,7 @@
// calculate the number of payments out of the other information
val = calc.numPayments();
if (val == 0)
- throw MYMONEYEXCEPTION("incorrect fincancial calculation");
+ throw MYMONEYEXCEPTION(QStringLiteral("incorrect fincancial calculation"));
// if the number of payments has a fractional part, then we
// round it to the smallest integer and calculate the balloon payment
@@ -389,7 +389,7 @@
|| (q->field("lendButton").toBool() && val > 0 && qAbs(val) > qAbs(calc.payment()))) {
// case a)
qDebug("Future Value is %f", val);
- throw MYMONEYEXCEPTION("incorrect fincancial calculation");
+ throw MYMONEYEXCEPTION(QStringLiteral("incorrect fincancial calculation"));
} else if ((q->field("borrowButton").toBool() && val < 0 && qAbs(val) <= qAbs(calc.payment()))
|| (q->field("lendButton").toBool() && val > 0 && qAbs(val) <= qAbs(calc.payment()))) {
@@ -402,7 +402,7 @@
if (q->field("finalPaymentEditValid").toBool()) {
if ((q->field("finalPaymentEdit").value().abs() - refVal.abs()).abs().toDouble() > 1) {
- throw MYMONEYEXCEPTION("incorrect fincancial calculation");
+ throw MYMONEYEXCEPTION(QStringLiteral("incorrect fincancial calculation"));
}
result = i18n("KMyMoney has successfully verified your loan information.");
}
diff --git a/kmymoney/wizards/newloanwizard/summarywizardpage.cpp b/kmymoney/wizards/newloanwizard/summarywizardpage.cpp
--- a/kmymoney/wizards/newloanwizard/summarywizardpage.cpp
+++ b/kmymoney/wizards/newloanwizard/summarywizardpage.cpp
@@ -91,7 +91,7 @@
try {
QStringList sel = field("interestAccountEdit").toStringList();
if (sel.count() != 1)
- throw MYMONEYEXCEPTION("Need a single selected interest category");
+ throw MYMONEYEXCEPTION(QStringLiteral("Need a single selected interest category"));
MyMoneyAccount acc = MyMoneyFile::instance()->account(sel.first());
ui->m_summaryInterestCategory->setText(acc.name());
} catch (const MyMoneyException &) {
@@ -104,7 +104,7 @@
try {
QStringList sel = field("paymentAccountEdit").toStringList();
if (sel.count() != 1)
- throw MYMONEYEXCEPTION("Need a single selected payment account");
+ throw MYMONEYEXCEPTION(QStringLiteral("Need a single selected payment account"));
MyMoneyAccount acc = MyMoneyFile::instance()->account(sel.first());
ui->m_summaryPaymentAccount->setText(acc.name());
} catch (const MyMoneyException &) {