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/supplicant_interface_proxy.cc b/supplicant_interface_proxy.cc
index 8281207..c4d6275 100644
--- a/supplicant_interface_proxy.cc
+++ b/supplicant_interface_proxy.cc
@@ -30,53 +30,99 @@
 ::DBus::Path SupplicantInterfaceProxy::AddNetwork(
     const std::map<std::string, ::DBus::Variant> &args) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.AddNetwork(args);
+  try {
+    return proxy_.AddNetwork(args);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " args keys are: " << DBusProperties::KeysToString(args);
+    return ::DBus::Path();  // Make the compiler happy.
+  }
 }
 
 void SupplicantInterfaceProxy::ClearCachedCredentials() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.ClearCachedCredentials();
+  try {
+    return proxy_.ClearCachedCredentials();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+  }
 }
 
 void SupplicantInterfaceProxy::Disconnect() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Disconnect();
+  try {
+    return proxy_.Disconnect();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+  }
 }
 
 void SupplicantInterfaceProxy::FlushBSS(const uint32_t &age) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.FlushBSS(age);
+  try {
+    return proxy_.FlushBSS(age);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " age: " << age;
+  }
 }
 
 void SupplicantInterfaceProxy::RemoveAllNetworks() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.RemoveAllNetworks();
+  try {
+    return proxy_.RemoveAllNetworks();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+  }
 }
 
 void SupplicantInterfaceProxy::RemoveNetwork(const ::DBus::Path &network) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.RemoveNetwork(network);
+  try {
+    return proxy_.RemoveNetwork(network);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+  }
 }
 
 void SupplicantInterfaceProxy::Scan(
     const std::map<std::string, ::DBus::Variant> &args) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Scan(args);
+  try {
+    return proxy_.Scan(args);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " args keys are: " << DBusProperties::KeysToString(args);
+  }
 }
 
 void SupplicantInterfaceProxy::SelectNetwork(const ::DBus::Path &network) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.SelectNetwork(network);
+  try {
+    return proxy_.SelectNetwork(network);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+  }
 }
 
 void SupplicantInterfaceProxy::SetFastReauth(bool enabled) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.FastReauth(enabled);
+  try {
+    return proxy_.FastReauth(enabled);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << "enabled: " << enabled;
+  }
 }
 
 void SupplicantInterfaceProxy::SetScanInterval(int32 scan_interval) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.ScanInterval(scan_interval);
+  try {
+    return proxy_.ScanInterval(scan_interval);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " scan interval: " << scan_interval;
+  }
 }
 
 // definitions for private class SupplicantInterfaceProxy::Proxy