Unify custom exceptions

This commit is contained in:
Vladimir Golovnev (Glassez)
2021-05-05 16:41:30 +03:00
parent 89cedd411e
commit 9565b695ef
13 changed files with 43 additions and 57 deletions

View File

@@ -114,7 +114,7 @@ AutoDownloader::AutoDownloader()
m_fileStorage = new AsyncFileStorage(
Utils::Fs::expandPathAbs(specialFolderLocation(SpecialFolder::Config) + ConfFolderName));
if (!m_fileStorage)
throw std::runtime_error("Directory for RSS AutoDownloader data is unavailable.");
throw RuntimeError(tr("Directory for RSS AutoDownloader data is unavailable."));
m_fileStorage->moveToThread(m_ioThread);
connect(m_ioThread, &QThread::finished, m_fileStorage, &AsyncFileStorage::deleteLater);
@@ -527,13 +527,3 @@ void AutoDownloader::timerEvent(QTimerEvent *event)
Q_UNUSED(event);
store();
}
ParsingError::ParsingError(const QString &message)
: std::runtime_error(message.toUtf8().data())
{
}
QString ParsingError::message() const
{
return what();
}

View File

@@ -28,8 +28,6 @@
#pragma once
#include <stdexcept>
#include <QBasicTimer>
#include <QHash>
#include <QList>
@@ -38,6 +36,8 @@
#include <QRegularExpression>
#include <QSharedPointer>
#include "base/exceptions.h"
class QThread;
class QTimer;
@@ -53,11 +53,10 @@ namespace RSS
class AutoDownloadRule;
class ParsingError : public std::runtime_error
class ParsingError : public RuntimeError
{
public:
explicit ParsingError(const QString &message);
QString message() const;
using RuntimeError::RuntimeError;
};
class AutoDownloader final : public QObject

View File

@@ -313,7 +313,7 @@ void Feed::loadArticles(const QByteArray &data)
if (!addArticle(article))
delete article;
}
catch (const std::runtime_error&) {}
catch (const RuntimeError &) {}
}
}
@@ -335,7 +335,7 @@ void Feed::loadArticlesLegacy()
if (!addArticle(article))
delete article;
}
catch (const std::runtime_error&) {}
catch (const RuntimeError &) {}
}
}