Replace error strings with logging errors in device operations
Change-Id: I0fc1c23e51a0233c18775ee712132dba7e4c7d7e
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
diff --git a/filedescriptor.cpp b/filedescriptor.cpp
index c8bcab0..9354d6e 100644
--- a/filedescriptor.cpp
+++ b/filedescriptor.cpp
@@ -16,6 +16,8 @@
#include <stdexcept>
#include <unistd.h>
#include "filedescriptor.hpp"
+#include <phosphor-logging/elog.hpp>
+#include "elog-errors.hpp"
namespace openpower
{
@@ -24,15 +26,15 @@
FileDescriptor::FileDescriptor(const std::string& path)
{
+ using namespace phosphor::logging;
+
fd = open(path.c_str(), O_RDWR | O_SYNC);
if (fd < 0)
{
- //Future: use a different exception to create an error log
- char msg[200];
- sprintf(msg, "Failed to open FSI device path %s. errno = %d",
- path.c_str(), errno);
- throw std::runtime_error(msg);
+ elog<org::open_power::Proc::CFAM::OpenFailure>(
+ org::open_power::Proc::CFAM::OpenFailure::ERRNO(errno),
+ org::open_power::Proc::CFAM::OpenFailure::PATH(path.c_str()));
}
}