summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-05-15 14:40:59 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-07-18 15:12:55 +0000
commit1469f8adc101962c1235f9477e9d53b5ba44e72b (patch)
tree3e290bcb770bfdd447d6e4299417511f8b904970 /app
parentc07e72cd1b5936f03c262904a243320514140d94 (diff)
downloadphosphor-host-ipmid-1469f8adc101962c1235f9477e9d53b5ba44e72b.zip
phosphor-host-ipmid-1469f8adc101962c1235f9477e9d53b5ba44e72b.tar.gz
app/watchdog_service: More useful error output
This patch adds error handling around the decoding of requests to the watchdog service, to give more useful context in the case of errors. Change-Id: If668b17e88dc65a938b69d8c2cdd760456170962 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'app')
-rw-r--r--app/watchdog_service.cpp58
1 files changed, 45 insertions, 13 deletions
diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
index 898cf77..6c9edd4 100644
--- a/app/watchdog_service.cpp
+++ b/app/watchdog_service.cpp
@@ -1,10 +1,12 @@
#include "watchdog_service.hpp"
+#include <exception>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/message.hpp>
+#include <stdexcept>
#include <string>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/State/Watchdog/server.hpp>
@@ -71,17 +73,31 @@ WatchdogService::Properties WatchdogService::getProperties()
log<level::ERR>("WatchdogService: Method error getting properties");
elog<InternalFailure>();
}
+ try
+ {
+ std::map<std::string, variant<bool, uint64_t, std::string>> properties;
+ response.read(properties);
+ Properties wd_prop;
+ wd_prop.initialized = get<bool>(properties.at("Initialized"));
+ wd_prop.enabled = get<bool>(properties.at("Enabled"));
+ wd_prop.expireAction = Watchdog::convertActionFromString(
+ get<std::string>(properties.at("ExpireAction")));
+ wd_prop.interval = get<uint64_t>(properties.at("Interval"));
+ wd_prop.timeRemaining = get<uint64_t>(properties.at("TimeRemaining"));
+ return wd_prop;
+ }
+ catch (const std::exception& e)
+ {
+ log<level::ERR>("WatchdogService: Decode error in get properties",
+ entry("ERROR=%s", e.what()),
+ entry("REPLY_SIG=%s", response.get_signature()));
+ elog<InternalFailure>();
+ }
- std::map<std::string, variant<bool, uint64_t, std::string>> properties;
- response.read(properties);
- Properties wd_prop;
- wd_prop.initialized = get<bool>(properties.at("Initialized"));
- wd_prop.enabled = get<bool>(properties.at("Enabled"));
- wd_prop.expireAction = Watchdog::convertActionFromString(
- get<std::string>(properties.at("ExpireAction")));
- wd_prop.interval = get<uint64_t>(properties.at("Interval"));
- wd_prop.timeRemaining = get<uint64_t>(properties.at("TimeRemaining"));
- return wd_prop;
+ // Needed instead of elog<InternalFailure>() since the compiler can't
+ // deduce the that elog<>() always throws
+ throw std::runtime_error(
+ "WatchdogService: Should not reach end of getProperties");
}
template <typename T>
@@ -103,9 +119,25 @@ T WatchdogService::getProperty(const std::string& key)
entry("PROPERTY=%s", key.c_str()));
elog<InternalFailure>();
}
- variant<T> value;
- response.read(value);
- return get<T>(value);
+ try
+ {
+ variant<T> value;
+ response.read(value);
+ return get<T>(value);
+ }
+ catch (const std::exception& e)
+ {
+ log<level::ERR>("WatchdogService: Decode error in get property",
+ entry("PROPERTY=%s", key.c_str()),
+ entry("ERROR=%s", e.what()),
+ entry("REPLY_SIG=%s", response.get_signature()));
+ elog<InternalFailure>();
+ }
+
+ // Needed instead of elog<InternalFailure>() since the compiler can't
+ // deduce the that elog<>() always throws
+ throw std::runtime_error(
+ "WatchdogService: Should not reach end of getProperty");
}
template <typename T>
OpenPOWER on IntegriCloud