summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-05-10 11:12:51 -0700
committerEmily Shaffer <emilyshaffer@google.com>2018-05-22 18:21:45 +0000
commit021b4c1a00e83699da844c6b641fca2066e29732 (patch)
tree0ce6d252c5683b4969815ef195d1747bec63695f /app
parenta59d83f8d62e2289d060aaa71892afcba32725cc (diff)
downloadphosphor-host-ipmid-021b4c1a00e83699da844c6b641fca2066e29732.zip
phosphor-host-ipmid-021b4c1a00e83699da844c6b641fca2066e29732.tar.gz
watchdog: Handle and report internal failures
An upcoming change will introduce InternalFailures instead of using runtime exceptions for error handling in the watchdog service. We need to handle these exceptions appropriately. Change-Id: Icfc02d98821f307a37a4cf59911913c820e88744 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'app')
-rw-r--r--app/watchdog.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index 7b1d987..c1f25ac 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -2,8 +2,11 @@
#include <cstdint>
#include <endian.h>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include <string>
+#include <xyz/openbmc_project/Common/error.hpp>
#include "watchdog_service.hpp"
#include "host-ipmid/ipmid-api.h"
@@ -11,6 +14,8 @@
using phosphor::logging::level;
using phosphor::logging::log;
+using phosphor::logging::report;
+using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
ipmi_ret_t ipmi_app_watchdog_reset(
ipmi_netfn_t netfn,
@@ -43,15 +48,22 @@ ipmi_ret_t ipmi_app_watchdog_reset(
return IPMI_CC_OK;
}
+ catch (const InternalFailure& e)
+ {
+ report<InternalFailure>();
+ return IPMI_CC_UNSPECIFIED_ERROR;
+ }
catch (const std::exception& e)
{
const std::string e_str = std::string("wd_reset: ") + e.what();
log<level::ERR>(e_str.c_str());
+ report<InternalFailure>();
return IPMI_CC_UNSPECIFIED_ERROR;
}
catch (...)
{
log<level::ERR>("wd_reset: Unknown Error");
+ report<InternalFailure>();
return IPMI_CC_UNSPECIFIED_ERROR;
}
}
@@ -155,15 +167,22 @@ ipmi_ret_t ipmi_app_watchdog_set(
{
return IPMI_CC_INVALID_FIELD_REQUEST;
}
+ catch (const InternalFailure& e)
+ {
+ report<InternalFailure>();
+ return IPMI_CC_UNSPECIFIED_ERROR;
+ }
catch (const std::exception& e)
{
const std::string e_str = std::string("wd_set: ") + e.what();
log<level::ERR>(e_str.c_str());
+ report<InternalFailure>();
return IPMI_CC_UNSPECIFIED_ERROR;
}
catch (...)
{
log<level::ERR>("wd_set: Unknown Error");
+ report<InternalFailure>();
return IPMI_CC_UNSPECIFIED_ERROR;
}
}
@@ -253,15 +272,22 @@ ipmi_ret_t ipmi_app_watchdog_get(
*data_len = sizeof(res);
return IPMI_CC_OK;
}
+ catch (const InternalFailure& e)
+ {
+ report<InternalFailure>();
+ return IPMI_CC_UNSPECIFIED_ERROR;
+ }
catch (const std::exception& e)
{
const std::string e_str = std::string("wd_get: ") + e.what();
log<level::ERR>(e_str.c_str());
+ report<InternalFailure>();
return IPMI_CC_UNSPECIFIED_ERROR;
}
catch (...)
{
log<level::ERR>("wd_get: Unknown Error");
+ report<InternalFailure>();
return IPMI_CC_UNSPECIFIED_ERROR;
}
}
OpenPOWER on IntegriCloud