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.cc b/dbus_properties.cc
index 5ad88b4..9a6d8dd 100644
--- a/dbus_properties.cc
+++ b/dbus_properties.cc
@@ -110,4 +110,16 @@
   return true;
 }
 
+// static
+std::string DBusProperties::KeysToString(const std::map<std::string,
+                                         ::DBus::Variant> &args) {
+  std::string keys;
+  for (std::map<std::string, ::DBus::Variant>:: const_iterator it =
+           args.begin(); it != args.end(); ++it) {
+    keys.append(" ");
+    keys.append(it->first);
+  }
+  return keys;
+}
+
 }  // namespace shill
diff --git a/dbus_properties.h b/dbus_properties.h
index 9257ed8..5e84a38 100644
--- a/dbus_properties.h
+++ b/dbus_properties.h
@@ -46,6 +46,9 @@
                         const std::string &key,
                         uint32 *value);
 
+  static std::string KeysToString(const std::map<std::string,
+                                  ::DBus::Variant> &args);
+
  private:
   DISALLOW_COPY_AND_ASSIGN(DBusProperties);
 };
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(
diff --git a/dhcpcd_proxy.cc b/dhcpcd_proxy.cc
index 8b9a9fc..ef53eb3 100644
--- a/dhcpcd_proxy.cc
+++ b/dhcpcd_proxy.cc
@@ -35,7 +35,13 @@
   SLOG(DBus, 2) << __func__;
   DBus::MessageIter ri = signal.reader();
   unsigned int pid;
-  ri >> pid;
+  try {
+    ri >> pid;
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " interface: " << signal.interface()
+               << " member: " << signal.member() << " path: " << signal.path();
+  }
   SLOG(DHCP, 2) << "sender(" << signal.sender() << ") pid(" << pid << ")";
 
   DHCPConfigRefPtr config = provider_->GetConfig(pid);
@@ -46,9 +52,21 @@
   config->InitProxy(signal.sender());
 
   string reason;
+  try {
   ri >> reason;
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " interface: " << signal.interface()
+               << " member: " << signal.member() << " path: " << signal.path();
+  }
   DHCPConfig::Configuration configuration;
-  ri >> configuration;
+  try {
+    ri >> configuration;
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " interface: " << signal.interface()
+               << " member: " << signal.member() << " path: " << signal.path();
+  }
   config->ProcessEventSignal(reason, configuration);
 }
 
@@ -57,7 +75,13 @@
   SLOG(DBus, 2) << __func__;
   DBus::MessageIter ri = signal.reader();
   unsigned int pid;
-  ri >> pid;
+  try {
+    ri >> pid;
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " interface: " << signal.interface()
+               << " member: " << signal.member() << " path: " << signal.path();
+  }
   SLOG(DHCP, 2) << "sender(" << signal.sender() << ") pid(" << pid << ")";
 
   // Accept StatusChanged signals just to get the sender address and create an
@@ -77,12 +101,22 @@
 
 void DHCPCDProxy::Rebind(const string &interface) {
   SLOG(DBus, 2) << __func__;
-  proxy_.Rebind(interface);
+  try {
+    proxy_.Rebind(interface);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " interface: " << interface;
+  }
 }
 
 void DHCPCDProxy::Release(const string &interface) {
   SLOG(DBus, 2) << __func__;
-  proxy_.Release(interface);
+  try {
+    proxy_.Release(interface);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " interface: " << interface;
+  }
 }
 
 DHCPCDProxy::Proxy::Proxy(DBus::Connection *connection,
diff --git a/mm1_modem_modem3gpp_proxy.cc b/mm1_modem_modem3gpp_proxy.cc
index b65e9f0..4bfad57 100644
--- a/mm1_modem_modem3gpp_proxy.cc
+++ b/mm1_modem_modem3gpp_proxy.cc
@@ -55,23 +55,48 @@
 // Inherited properties from ModemModem3gppProxyInterface.
 std::string ModemModem3gppProxy::Imei() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Imei();
+  try {
+    return proxy_.Imei();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 };
 uint32_t ModemModem3gppProxy::RegistrationState() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.RegistrationState();
+  try {
+    return proxy_.RegistrationState();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 };
 std::string ModemModem3gppProxy::OperatorCode() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.OperatorCode();
+  try {
+    return proxy_.OperatorCode();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 };
 std::string ModemModem3gppProxy::OperatorName() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.OperatorName();
+  try {
+    return proxy_.OperatorName();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 };
 uint32_t ModemModem3gppProxy::EnabledFacilityLocks() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.EnabledFacilityLocks();
+  try {
+    return proxy_.EnabledFacilityLocks();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 };
 
 // ModemModem3gppProxy::Proxy
diff --git a/mm1_modem_modemcdma_proxy.cc b/mm1_modem_modemcdma_proxy.cc
index b334829..e1b57bf 100644
--- a/mm1_modem_modemcdma_proxy.cc
+++ b/mm1_modem_modemcdma_proxy.cc
@@ -60,27 +60,57 @@
 // Inherited properties from ModemModemCdmaProxyInterface.
 std::string ModemModemCdmaProxy::Meid() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Meid();
+  try {
+    return proxy_.Meid();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 };
 std::string ModemModemCdmaProxy::Esn() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Esn();
+  try {
+    return proxy_.Esn();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 };
 uint32_t ModemModemCdmaProxy::Sid() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Sid();
+  try {
+    return proxy_.Sid();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 };
 uint32_t ModemModemCdmaProxy::Nid() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Nid();
+  try {
+    return proxy_.Nid();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 };
 uint32_t ModemModemCdmaProxy::Cdma1xRegistrationState() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Cdma1xRegistrationState();
+  try {
+    return proxy_.Cdma1xRegistrationState();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 };
 uint32_t ModemModemCdmaProxy::EvdoRegistrationState() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.EvdoRegistrationState();
+  try {
+    return proxy_.EvdoRegistrationState();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 };
 
 // ModemModemCdmaProxy::Proxy
diff --git a/mm1_modem_proxy.cc b/mm1_modem_proxy.cc
index 13e7f4c..bbedbe8 100644
--- a/mm1_modem_proxy.cc
+++ b/mm1_modem_proxy.cc
@@ -132,7 +132,7 @@
   }
 }
 
-void ModemProxy::SetBands(const std::vector< uint32_t > &bands,
+void ModemProxy::SetBands(const std::vector<uint32_t> &bands,
                           Error *error,
                           const ResultCallback &callback,
                           int timeout) {
@@ -166,99 +166,219 @@
 // Inherited properties from ModemProxyInterface.
 const ::DBus::Path ModemProxy::Sim() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Sim();
+  try {
+    return proxy_.Sim();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return ::DBus::Path();  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::ModemCapabilities() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.ModemCapabilities();
+  try {
+    return proxy_.ModemCapabilities();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::CurrentCapabilities() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.CurrentCapabilities();
+  try {
+    return proxy_.CurrentCapabilities();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::MaxBearers() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.MaxBearers();
+  try {
+    return proxy_.MaxBearers();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::MaxActiveBearers() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.MaxActiveBearers();
+  try {
+    return proxy_.MaxActiveBearers();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 const std::string ModemProxy::Manufacturer() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Manufacturer();
+  try {
+    return proxy_.Manufacturer();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 }
 const std::string ModemProxy::Model() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Model();
+  try {
+    return proxy_.Model();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 }
 const std::string ModemProxy::Revision() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Revision();
+  try {
+    return proxy_.Revision();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 }
 const std::string ModemProxy::DeviceIdentifier() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.DeviceIdentifier();
+  try {
+    return proxy_.DeviceIdentifier();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 }
 const std::string ModemProxy::Device() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Device();
+  try {
+    return proxy_.Device();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 }
 const std::string ModemProxy::Driver() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Driver();
+  try {
+    return proxy_.Driver();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 }
 const std::string ModemProxy::Plugin() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Plugin();
+  try {
+    return proxy_.Plugin();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 }
 const std::string ModemProxy::EquipmentIdentifier() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.EquipmentIdentifier();
+  try {
+    return proxy_.EquipmentIdentifier();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::string();  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::UnlockRequired() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.UnlockRequired();
+  try {
+    return proxy_.UnlockRequired();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
-const std::map< uint32_t, uint32_t > ModemProxy::UnlockRetries() {
+const std::map<uint32_t, uint32_t> ModemProxy::UnlockRetries() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.UnlockRetries();
+  try {
+    return proxy_.UnlockRetries();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::map<uint32_t, uint32_t>();  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::State() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.State();
+  try {
+    return proxy_.State();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::AccessTechnologies() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.AccessTechnologies();
+  try {
+    return proxy_.AccessTechnologies();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
-const ::DBus::Struct< uint32_t, bool > ModemProxy::SignalQuality() {
+const ::DBus::Struct<uint32_t, bool> ModemProxy::SignalQuality() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.SignalQuality();
+  try {
+    return proxy_.SignalQuality();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return ::DBus::Struct<uint32_t, bool>();  // Make the compiler happy.
+  }
 }
 const std::vector<string> ModemProxy::OwnNumbers() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.OwnNumbers();
+  try {
+    return proxy_.OwnNumbers();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::vector<string>();  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::SupportedModes() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.SupportedModes();
+  try {
+    return proxy_.SupportedModes();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::AllowedModes() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.AllowedModes();
+  try {
+    return proxy_.AllowedModes();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 uint32_t ModemProxy::PreferredMode() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.PreferredMode();
+  try {
+    return proxy_.PreferredMode();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
-const std::vector< uint32_t > ModemProxy::SupportedBands() {
+const std::vector<uint32_t> ModemProxy::SupportedBands() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.SupportedBands();
+  try {
+    return proxy_.SupportedBands();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::vector<uint32_t>();  // Make the compiler happy.
+  }
 }
-const std::vector< uint32_t > ModemProxy::Bands() {
+const std::vector<uint32_t> ModemProxy::Bands() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Bands();
+  try {
+    return proxy_.Bands();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return std::vector<uint32_t>();  // Make the compiler happy.
+  }
 }
 
 ModemProxy::Proxy::Proxy(DBus::Connection *connection,
@@ -294,7 +414,7 @@
 }
 
 void ModemProxy::Proxy::ListBearersCallback(
-    const std::vector< ::DBus::Path > &bearers,
+    const std::vector< ::DBus::Path> &bearers,
     const ::DBus::Error& dberror,
     void *data) {
   SLOG(DBus, 2) << __func__;
diff --git a/mm1_sim_proxy.cc b/mm1_sim_proxy.cc
index e7ad709..c2bfb3e 100644
--- a/mm1_sim_proxy.cc
+++ b/mm1_sim_proxy.cc
@@ -96,22 +96,42 @@
 // Inherited properties from SimProxyInterface.
 const string SimProxy::SimIdentifier() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.SimIdentifier();
+  try {
+    return proxy_.SimIdentifier();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return string();  // Make the compiler happy.
+  }
 }
 
 const string SimProxy::Imsi() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.Imsi();
+  try {
+    return proxy_.Imsi();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return string();  // Make the compiler happy.
+  }
 }
 
 const string SimProxy::OperatorIdentifier() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.OperatorIdentifier();
+  try {
+    return proxy_.OperatorIdentifier();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return string();  // Make the compiler happy.
+  }
 }
 
 const string SimProxy::OperatorName() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.OperatorName();
+  try {
+    return proxy_.OperatorName();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return string();  // Make the compiler happy.
+  }
 }
 
 SimProxy::Proxy::Proxy(DBus::Connection *connection,
diff --git a/modem_cdma_proxy.cc b/modem_cdma_proxy.cc
index edda190..4395eb0 100644
--- a/modem_cdma_proxy.cc
+++ b/modem_cdma_proxy.cc
@@ -69,7 +69,12 @@
 const string ModemCDMAProxy::MEID() {
   LOG(INFO) << "ModemCDMAProxy::" << __func__;
   SLOG(DBus, 2) << __func__;
-  return proxy_.Meid();
+  try {
+    return proxy_.Meid();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return string();  // Make the compiler happy.
+  }
 }
 
 void ModemCDMAProxy::set_activation_state_callback(
diff --git a/modem_gsm_card_proxy.cc b/modem_gsm_card_proxy.cc
index f1cf073..c06f7c4 100644
--- a/modem_gsm_card_proxy.cc
+++ b/modem_gsm_card_proxy.cc
@@ -142,7 +142,12 @@
 
 uint32 ModemGSMCardProxy::EnabledFacilityLocks() {
   SLOG(DBus, 2) << __func__;
-  return proxy_.EnabledFacilityLocks();
+  try {
+    return proxy_.EnabledFacilityLocks();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 
 ModemGSMCardProxy::Proxy::Proxy(DBus::Connection *connection,
diff --git a/modem_gsm_network_proxy.cc b/modem_gsm_network_proxy.cc
index a11a563..37f67ba 100644
--- a/modem_gsm_network_proxy.cc
+++ b/modem_gsm_network_proxy.cc
@@ -85,7 +85,12 @@
 
 uint32 ModemGSMNetworkProxy::AccessTechnology() {
   SLOG(DBus, 2) << __func__;
+  try {
   return proxy_.AccessTechnology();
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+    return 0;  // Make the compiler happy.
+  }
 }
 
 void ModemGSMNetworkProxy::set_signal_quality_callback(
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,
diff --git a/power_manager_proxy.cc b/power_manager_proxy.cc
index 1b6d381..6b9b930 100644
--- a/power_manager_proxy.cc
+++ b/power_manager_proxy.cc
@@ -21,7 +21,12 @@
 
 void PowerManagerProxy::RegisterSuspendDelay(uint32 delay_ms) {
   SLOG(DBus, 2) << __func__;
-  proxy_.RegisterSuspendDelay(delay_ms);
+  try {
+    proxy_.RegisterSuspendDelay(delay_ms);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << "delay ms: " << delay_ms;
+  }
 }
 
 PowerManagerProxy::Proxy::Proxy(PowerManagerProxyDelegate *delegate,
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
diff --git a/supplicant_process_proxy.cc b/supplicant_process_proxy.cc
index 61fa026..248a9dc 100644
--- a/supplicant_process_proxy.cc
+++ b/supplicant_process_proxy.cc
@@ -10,6 +10,7 @@
 #include <base/logging.h>
 #include <dbus-c++/dbus.h>
 
+#include "shill/dbus_properties.h"
 #include "shill/scope_logger.h"
 
 using std::map;
@@ -27,17 +28,33 @@
 ::DBus::Path SupplicantProcessProxy::CreateInterface(
     const map<string, ::DBus::Variant> &args) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.CreateInterface(args);
+  try {
+    return proxy_.CreateInterface(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 SupplicantProcessProxy::RemoveInterface(const ::DBus::Path &path) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.RemoveInterface(path);
+  try {
+    return proxy_.RemoveInterface(path);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
+  }
 }
 
 ::DBus::Path SupplicantProcessProxy::GetInterface(const string &ifname) {
   SLOG(DBus, 2) << __func__;
-  return proxy_.GetInterface(ifname);
+  try {
+    return proxy_.GetInterface(ifname);
+  } catch (const DBus::Error &e) {
+    LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
+               << " ifname: " << ifname;
+    return ::DBus::Path();  // Make the compiler happy.
+  }
 }
 
 // definitions for private class SupplicantProcessProxy::Proxy