From 021b4c1a00e83699da844c6b641fca2066e29732 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Thu, 10 May 2018 11:12:51 -0700 Subject: 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 --- app/watchdog.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 #include +#include +#include #include #include +#include #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(); + return IPMI_CC_UNSPECIFIED_ERROR; + } catch (const std::exception& e) { const std::string e_str = std::string("wd_reset: ") + e.what(); log(e_str.c_str()); + report(); return IPMI_CC_UNSPECIFIED_ERROR; } catch (...) { log("wd_reset: Unknown Error"); + report(); 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(); + return IPMI_CC_UNSPECIFIED_ERROR; + } catch (const std::exception& e) { const std::string e_str = std::string("wd_set: ") + e.what(); log(e_str.c_str()); + report(); return IPMI_CC_UNSPECIFIED_ERROR; } catch (...) { log("wd_set: Unknown Error"); + report(); 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(); + return IPMI_CC_UNSPECIFIED_ERROR; + } catch (const std::exception& e) { const std::string e_str = std::string("wd_get: ") + e.what(); log(e_str.c_str()); + report(); return IPMI_CC_UNSPECIFIED_ERROR; } catch (...) { log("wd_get: Unknown Error"); + report(); return IPMI_CC_UNSPECIFIED_ERROR; } } -- cgit v1.2.1