Don't use output parameters for error handling

This commit is contained in:
Vladimir Golovnev (Glassez) 2021-10-06 21:45:37 +03:00
commit 41fc0fd084
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
12 changed files with 116 additions and 165 deletions

View file

@ -701,14 +701,14 @@ void TorrentsController::addAction()
for (auto it = data().constBegin(); it != data().constEnd(); ++it)
{
const BitTorrent::TorrentInfo torrentInfo = BitTorrent::TorrentInfo::load(it.value());
if (!torrentInfo.isValid())
const nonstd::expected<BitTorrent::TorrentInfo, QString> result = BitTorrent::TorrentInfo::load(it.value());
if (!result)
{
throw APIError(APIErrorType::BadData
, tr("Error: '%1' is not a valid torrent file.").arg(it.key()));
}
partialSuccess |= BitTorrent::Session::instance()->addTorrent(torrentInfo, addTorrentParams);
partialSuccess |= BitTorrent::Session::instance()->addTorrent(result.value(), addTorrentParams);
}
if (partialSuccess)