catch some exceptions
This commit is contained in:
parent
bf5d182f2a
commit
93da8822ef
6 changed files with 32 additions and 12 deletions
|
@ -30,7 +30,7 @@
|
||||||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||||
<content_rating type="oars-1.1" />
|
<content_rating type="oars-1.1" />
|
||||||
<releases>
|
<releases>
|
||||||
<release version="3.9.0" date="2021-03-09"/>
|
<release version="3.9.0" date="2021-03-10"/>
|
||||||
</releases>
|
</releases>
|
||||||
<content_rating type="oars-1.0">
|
<content_rating type="oars-1.0">
|
||||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||||
|
|
|
@ -157,7 +157,6 @@ QList<ServiceRoot*> DatabaseQueries::getAccounts(const QSqlDatabase& db, const Q
|
||||||
ServiceRoot* root = new T();
|
ServiceRoot* root = new T();
|
||||||
|
|
||||||
// Load common data.
|
// Load common data.
|
||||||
//root->setId(query.value(QSL("id")).toInt());
|
|
||||||
root->setAccountId(query.value(QSL("id")).toInt());
|
root->setAccountId(query.value(QSL("id")).toInt());
|
||||||
|
|
||||||
QNetworkProxy proxy(QNetworkProxy::ProxyType(query.value(QSL("proxy_type")).toInt()),
|
QNetworkProxy proxy(QNetworkProxy::ProxyType(query.value(QSL("proxy_type")).toInt()),
|
||||||
|
|
|
@ -161,6 +161,9 @@ class RSSGUARD_DLLSPEC RootItem : public QObject {
|
||||||
// This ALWAYS represents primary column number/ID under which
|
// This ALWAYS represents primary column number/ID under which
|
||||||
// the item is stored in DB.
|
// the item is stored in DB.
|
||||||
int id() const;
|
int id() const;
|
||||||
|
|
||||||
|
// WARNING: Do not EVER call this method if your "this" object is derived
|
||||||
|
// from "ServiceRoot";
|
||||||
void setId(int id);
|
void setId(int id);
|
||||||
|
|
||||||
// Each item has its title.
|
// Each item has its title.
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
#include "3rd-party/boolinq/boolinq.h"
|
#include "3rd-party/boolinq/boolinq.h"
|
||||||
#include "core/feedsmodel.h"
|
#include "core/feedsmodel.h"
|
||||||
#include "core/messagesmodel.h"
|
#include "core/messagesmodel.h"
|
||||||
#include "miscellaneous/application.h"
|
|
||||||
#include "database/databasequeries.h"
|
#include "database/databasequeries.h"
|
||||||
|
#include "exceptions/applicationexception.h"
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "miscellaneous/textfactory.h"
|
#include "miscellaneous/textfactory.h"
|
||||||
#include "services/abstract/cacheforserviceroot.h"
|
#include "services/abstract/cacheforserviceroot.h"
|
||||||
|
@ -281,7 +282,12 @@ ServiceRoot::LabelOperation ServiceRoot::supportedLabelOperations() const {
|
||||||
void ServiceRoot::saveAccountDataToDatabase() {
|
void ServiceRoot::saveAccountDataToDatabase() {
|
||||||
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
||||||
|
|
||||||
DatabaseQueries::createOverwriteAccount(database, this);
|
try {
|
||||||
|
DatabaseQueries::createOverwriteAccount(database, this);
|
||||||
|
}
|
||||||
|
catch (const ApplicationException& ex) {
|
||||||
|
qFatal("Account was not saved into database: '%s'.", qPrintable(ex.message()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantHash ServiceRoot::customDatabaseData() const {
|
QVariantHash ServiceRoot::customDatabaseData() const {
|
||||||
|
|
|
@ -215,7 +215,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
QString feed_type = child_element.attribute(QSL("version"), DEFAULT_FEED_TYPE).toUpper();
|
QString feed_type = child_element.attribute(QSL("version"), DEFAULT_FEED_TYPE).toUpper();
|
||||||
QString feed_description = child_element.attribute(QSL("description"));
|
QString feed_description = child_element.attribute(QSL("description"));
|
||||||
QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
||||||
QString source_type = child_element.attribute(QSL("rssguard:xmlUrlType"));
|
StandardFeed::SourceType source_type = StandardFeed::SourceType(child_element.attribute(QSL("rssguard:xmlUrlType")).toInt());
|
||||||
QString post_process = child_element.attribute(QSL("rssguard:postProcess"));
|
QString post_process = child_element.attribute(QSL("rssguard:postProcess"));
|
||||||
auto* new_feed = new StandardFeed(active_model_item);
|
auto* new_feed = new StandardFeed(active_model_item);
|
||||||
|
|
||||||
|
@ -224,6 +224,8 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||||
new_feed->setEncoding(feed_encoding);
|
new_feed->setEncoding(feed_encoding);
|
||||||
new_feed->setSource(feed_url);
|
new_feed->setSource(feed_url);
|
||||||
new_feed->setCreationDate(QDateTime::currentDateTime());
|
new_feed->setCreationDate(QDateTime::currentDateTime());
|
||||||
|
new_feed->setSourceType(source_type);
|
||||||
|
new_feed->setPostProcessScript(post_process);
|
||||||
|
|
||||||
if (!feed_icon.isNull()) {
|
if (!feed_icon.isNull()) {
|
||||||
new_feed->setIcon(feed_icon);
|
new_feed->setIcon(feed_icon);
|
||||||
|
|
|
@ -318,7 +318,9 @@ QList<QAction*> StandardServiceRoot::getContextMenuForFeed(StandardFeed* feed) {
|
||||||
return m_feedContextMenu;
|
return m_feedContextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model, RootItem* target_root_node, QString& output_message) {
|
bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model,
|
||||||
|
RootItem* target_root_node,
|
||||||
|
QString& output_message) {
|
||||||
QStack<RootItem*> original_parents;
|
QStack<RootItem*> original_parents;
|
||||||
|
|
||||||
original_parents.push(target_root_node);
|
original_parents.push(target_root_node);
|
||||||
|
@ -385,17 +387,25 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model,
|
||||||
auto* new_feed = new StandardFeed(*source_feed);
|
auto* new_feed = new StandardFeed(*source_feed);
|
||||||
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
||||||
|
|
||||||
DatabaseQueries::createOverwriteFeed(database,
|
try {
|
||||||
new_feed,
|
DatabaseQueries::createOverwriteFeed(database,
|
||||||
target_root_node->getParentServiceRoot()->accountId(),
|
new_feed,
|
||||||
target_parent->id());
|
target_root_node->getParentServiceRoot()->accountId(),
|
||||||
requestItemReassignment(new_feed, target_parent);
|
target_parent->id());
|
||||||
|
requestItemReassignment(new_feed, target_parent);
|
||||||
|
}
|
||||||
|
catch (const ApplicationException& ex) {
|
||||||
|
qCriticalNN << LOGSEC_CORE
|
||||||
|
<< "Cannot import feed:"
|
||||||
|
<< QUOTE_W_SPACE_DOT(ex.message());
|
||||||
|
some_feed_category_error = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (some_feed_category_error) {
|
if (some_feed_category_error) {
|
||||||
output_message = tr("Import successful, but some feeds/categories were not imported due to error.");
|
output_message = tr("Some feeds/categories were not imported due to error, check debug log for more details.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
output_message = tr("Import was completely successful.");
|
output_message = tr("Import was completely successful.");
|
||||||
|
|
Loading…
Add table
Reference in a new issue