shill: Wrap calls to dbus proxies in try-catch blocks
Many functions of the dbus-c++ library throw exceptions. These
functions are called by proxies in shill. Calls to dbus-c++
functions should be wrapped in try-catch blocks so that they
can handle the exception or at least log a meaningful error.
BUG=chromium-os:30566
TEST=Ran unit tests.
Change-Id: I6063812782f1b1662c6775c140c7f26480ea5fc8
Reviewed-on: https://gerrit.chromium.org/gerrit/21904
Commit-Ready: Gary Morain <gmorain@chromium.org>
Reviewed-by: Gary Morain <gmorain@chromium.org>
Tested-by: Gary Morain <gmorain@chromium.org>
Reviewed-by: Jason Glasgow <jglasgow@chromium.org>
diff --git a/dbus_properties_proxy.cc b/dbus_properties_proxy.cc
index 728f806..2b2d3e3 100644
--- a/dbus_properties_proxy.cc
+++ b/dbus_properties_proxy.cc
@@ -20,7 +20,13 @@
DBusPropertiesMap DBusPropertiesProxy::GetAll(const string &interface_name) {
SLOG(DBus, 2) << __func__ << "(" << interface_name << ")";
- return proxy_.GetAll(interface_name);
+ try {
+ return proxy_.GetAll(interface_name);
+ } catch (const DBus::Error &e) {
+ LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+ << " interface name: " << interface_name;
+ return DBusPropertiesMap(); // Make the compiler happy.
+ }
}
void DBusPropertiesProxy::set_properties_changed_callback(