summaryrefslogtreecommitdiffstats
path: root/control/main.cpp
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-04-25 15:26:10 -0500
committerMatthew Barth <msbarth@us.ibm.com>2018-05-09 10:15:35 -0500
commitba7b5fea818f65949cd074de9322094d3c54fb7b (patch)
tree953b30c25fa2086bd56f2af340965adbd8244f55 /control/main.cpp
parent84f105b7f83bcafc28f3b9c30592cd754af44719 (diff)
downloadphosphor-fan-presence-ba7b5fea818f65949cd074de9322094d3c54fb7b.tar.gz
phosphor-fan-presence-ba7b5fea818f65949cd074de9322094d3c54fb7b.zip
Throw custom exceptions on D-Bus method failures
All 3 fan applications - control, monitor, and presence have cases where it is expected that a getProperty call may fail because a sensor is missing. While the applications already handle this, the InternalFailure exception that was being thrown by the underlying call generates log entries that make it look like something bad happened. The custom exceptions now being thrown do not log anything on creation, but store all of the failing information so that any callers could still log the info if they wanted to. Tested: Boot a water cooled Witherspoon and see the fan presence and monitor applications not look like they are failing. Boot a system without the fan hwmon running, and see fan-control-init still show the fails. Change-Id: Ifd8ad6e3deb492bbaf33f12c7258125dce1e5ea8 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'control/main.cpp')
-rw-r--r--control/main.cpp44
1 files changed, 32 insertions, 12 deletions
diff --git a/control/main.cpp b/control/main.cpp
index cde71d0..dd9330d 100644
--- a/control/main.cpp
+++ b/control/main.cpp
@@ -18,6 +18,7 @@
#include "argument.hpp"
#include "manager.hpp"
#include "event.hpp"
+#include "sdbusplus.hpp"
using namespace phosphor::fan::control;
using namespace phosphor::logging;
@@ -64,22 +65,41 @@ int main(int argc, char* argv[])
//handle both sd_events (for the timers) and dbus signals.
bus.attach_event(eventPtr.get(), SD_EVENT_PRIORITY_NORMAL);
- Manager manager(bus, eventPtr, mode);
+ try
+ {
+ Manager manager(bus, eventPtr, mode);
- //Init mode will just set fans to max and delay
- if (mode == Mode::init)
+ //Init mode will just set fans to max and delay
+ if (mode == Mode::init)
+ {
+ manager.doInit();
+ return 0;
+ }
+ else
+ {
+ r = sd_event_loop(eventPtr.get());
+ if (r < 0)
+ {
+ log<level::ERR>("Failed call to sd_event_loop",
+ entry("ERROR=%s", strerror(-r)));
+ }
+ }
+ }
+ //Log the useful metadata on these exceptions and let the app
+ //return -1 so it is restarted without a core dump.
+ catch (phosphor::fan::util::DBusServiceError& e)
{
- manager.doInit();
- return 0;
+ log<level::ERR>("Uncaught DBus service lookup failure exception",
+ entry("PATH=%s", e.path.c_str()),
+ entry("INTERFACE=%s", e.interface.c_str()));
}
- else
+ catch (phosphor::fan::util::DBusMethodError& e)
{
- r = sd_event_loop(eventPtr.get());
- if (r < 0)
- {
- log<level::ERR>("Failed call to sd_event_loop",
- entry("ERROR=%s", strerror(-r)));
- }
+ log<level::ERR>("Uncaught DBus method failure exception",
+ entry("BUSNAME=%s", e.busName.c_str()),
+ entry("PATH=%s", e.path.c_str()),
+ entry("INTERFACE=%s", e.interface.c_str()),
+ entry("METHOD=%s", e.method.c_str()));
}
return -1;
OpenPOWER on IntegriCloud