summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-10-06 13:42:39 -0500
committerGunnar Mills <gmills@us.ibm.com>2017-10-08 16:39:04 -0500
commitaae1b2bbc1e7eb358a756606374c9a600b340542 (patch)
tree193fed82de313c73d08b032405a9c784e5e7b56c
parent484429175d8806d80d2cc7e876e5e6a8834d55d7 (diff)
downloadphosphor-bmc-code-mgmt-aae1b2bbc1e7eb358a756606374c9a600b340542.tar.gz
phosphor-bmc-code-mgmt-aae1b2bbc1e7eb358a756606374c9a600b340542.zip
Switch from runtime_error to elog
No longer throw a runtime_error when an error occurs in getValue, getId, or getBMCVersion. Instead, elog an error. These functions in openpower-pnor-code-mgmt, already do this. Change-Id: Id0d5173705d9d014e298812c4561cf4bc1ee8910 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rw-r--r--version.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/version.cpp b/version.cpp
index 133e5a4..6377afb 100644
--- a/version.cpp
+++ b/version.cpp
@@ -3,10 +3,12 @@
#include <sstream>
#include <fstream>
#include <stdexcept>
+#include <openssl/sha.h>
#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include "xyz/openbmc_project/Common/error.hpp"
#include "config.h"
#include "version.hpp"
-#include <openssl/sha.h>
namespace phosphor
{
@@ -16,6 +18,8 @@ namespace manager
{
using namespace phosphor::logging;
+using Argument = xyz::openbmc_project::Common::InvalidArgument;
+using namespace sdbusplus::xyz::openbmc_project::Common::Error;
std::string Version::getValue(const std::string& manifestFilePath,
std::string key)
@@ -26,15 +30,17 @@ std::string Version::getValue(const std::string& manifestFilePath,
if (manifestFilePath.empty())
{
log<level::ERR>("Error MANIFESTFilePath is empty");
- throw std::runtime_error("MANIFESTFilePath is empty");
+ elog<InvalidArgument>(
+ Argument::ARGUMENT_NAME("manifestFilePath"),
+ Argument::ARGUMENT_VALUE(manifestFilePath.c_str()));
}
std::string value{};
std::ifstream efile;
std::string line;
- efile.exceptions(std::ifstream::failbit
- | std::ifstream::badbit
- | std::ifstream::eofbit);
+ efile.exceptions(std::ifstream::failbit |
+ std::ifstream::badbit |
+ std::ifstream::eofbit);
// Too many GCC bugs (53984, 66145) to do this the right way...
try
@@ -64,7 +70,8 @@ std::string Version::getId(const std::string& version)
if (version.empty())
{
log<level::ERR>("Error version is empty");
- throw std::runtime_error("Version is empty");
+ elog<InvalidArgument>(Argument::ARGUMENT_NAME("Version"),
+ Argument::ARGUMENT_VALUE(version.c_str()));
}
unsigned char digest[SHA512_DIGEST_LENGTH];
@@ -106,7 +113,7 @@ std::string Version::getBMCVersion(const std::string& releaseFilePath)
if (version.empty())
{
log<level::ERR>("Error BMC current version is empty");
- throw std::runtime_error("BMC current version is empty");
+ elog<InternalFailure>();
}
return version;
OpenPOWER on IntegriCloud