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/modem_manager_proxy.cc b/modem_manager_proxy.cc
index d607998..c491b94 100644
--- a/modem_manager_proxy.cc
+++ b/modem_manager_proxy.cc
@@ -24,7 +24,12 @@
vector<DBus::Path> ModemManagerProxy::EnumerateDevices() {
SLOG(DBus, 2) << __func__;
- return proxy_.EnumerateDevices();
+ try {
+ return proxy_.EnumerateDevices();
+ } catch (const DBus::Error &e) {
+ LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+ return vector<DBus::Path>(); // Make the compiler happy.
+ }
}
ModemManagerProxy::Proxy::Proxy(DBus::Connection *connection,