Commit c3f6cd23 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

don't assert that there is 1 product

...there may be none!

we'll throw this as an exception to trigger error signaling in
bugzillalib.cpp. Alas, as it turns out this isn't actually wired up to
anything. so this effectively just turns the failed assert (which may
crash) into a runtimexception (which never crashes).

to reasonably deal with this the wizard will need some improvements as
well
parent 523ddb07
/*
SPDX-FileCopyrightText: 2019 Harald Sitter <sitter@kde.org>
SPDX-FileCopyrightText: 2019-2021 Harald Sitter <sitter@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
......@@ -10,6 +10,7 @@
#include <QMetaObject>
#include <QMetaType>
#include <QSharedPointer>
namespace Bugzilla
{
Product::Ptr ProductClient::get(KJob *kjob)
......@@ -17,6 +18,9 @@ Product::Ptr ProductClient::get(KJob *kjob)
auto job = qobject_cast<APIJob *>(kjob);
const QJsonArray productsArray = job->object().value(QLatin1String("products")).toArray();
if (productsArray.isEmpty()) {
throw Bugzilla::RuntimeException(QStringLiteral("Failed to resolve bugzilla product"));
}
Q_ASSERT(productsArray.size() == 1);
auto obj = productsArray.at(0).toObject().toVariantHash();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment