Skip to content

Commit

Permalink
ui/network: add error handing for dbus call (commaai#32164)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee authored Apr 25, 2024
1 parent 3bcb6f8 commit d7d378a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions selfdrive/ui/qt/network/wifi_manager.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "selfdrive/ui/qt/network/wifi_manager.h"

#include <utility>

#include "selfdrive/ui/ui.h"
#include "selfdrive/ui/qt/widgets/prime.h"

Expand All @@ -14,9 +16,15 @@ bool compare_by_strength(const Network &a, const Network &b) {

template <typename T = QDBusMessage, typename... Args>
T call(const QString &path, const QString &interface, const QString &method, Args &&...args) {
QDBusInterface nm = QDBusInterface(NM_DBUS_SERVICE, path, interface, QDBusConnection::systemBus());
QDBusInterface nm(NM_DBUS_SERVICE, path, interface, QDBusConnection::systemBus());
nm.setTimeout(DBUS_TIMEOUT);
QDBusMessage response = nm.call(method, args...);

QDBusMessage response = nm.call(method, std::forward<Args>(args)...);
if (response.type() == QDBusMessage::ErrorMessage) {
qCritical() << "DBus call error:" << response.errorMessage();
return T();
}

if constexpr (std::is_same_v<T, QDBusMessage>) {
return response;
} else if (response.arguments().count() >= 1) {
Expand Down

0 comments on commit d7d378a

Please sign in to comment.