From 8f0241d29a4c649f9a97346794719616c0180abb Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 11 Jan 2017 13:32:13 +0100 Subject: [PATCH] Provide an error message as warning output As discussed in the issue #97, there's some systems where appstream is reporting that it doesn't load properly but the users on the platform don't have information on how to fix it. Provide a warning for frontends to display, giving indications on what's the problem. --- qt/pool.cpp | 14 ++++++++++++-- qt/pool.h | 7 +++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/qt/pool.cpp b/qt/pool.cpp index 4da656ba..f59253ff 100644 --- a/qt/pool.cpp +++ b/qt/pool.cpp @@ -64,9 +64,19 @@ Pool::~Pool() // empty. needed for the scoped pointer for the private pointer } -bool Pool::load() +bool AppStream::Pool::load() { - return as_pool_load (d->m_pool, NULL, NULL); + return load(nullptr); +} + +bool Pool::load(QString* strerror) +{ + g_autoptr(GError) error = nullptr; + bool ret = as_pool_load (d->m_pool, NULL, &error); + if (!ret && error) { + *strerror = QString::fromUtf8(error->message); + } + return ret; } void Pool::clear() diff --git a/qt/pool.h b/qt/pool.h index 248949b1..144b3288 100644 --- a/qt/pool.h +++ b/qt/pool.h @@ -76,6 +76,13 @@ Q_OBJECT */ bool load(); + /** + * \return true on success. False on failure + * + * In case of failure, @p error will be initialized with the error message + */ + bool load(QString* error); + /** * Remove all software component information from the pool. */