Create error log on fail

Use elog to create error log on fail.

Change-Id: I27863f5102f56fa04defbab1831c462bf152f771
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/download_manager.cpp b/download_manager.cpp
index 434ece9..f5ff54b 100644
--- a/download_manager.cpp
+++ b/download_manager.cpp
@@ -4,6 +4,9 @@
 #include <sys/wait.h>
 #include <phosphor-logging/log.hpp>
 #include "config.h"
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include "xyz/openbmc_project/Common/error.hpp"
 #include "download_manager.hpp"
 
 namespace phosphor
@@ -13,6 +16,7 @@
 namespace manager
 {
 
+using namespace sdbusplus::xyz::openbmc_project::Common::Error;
 using namespace phosphor::logging;
 
 void Download::downloadViaTFTP(const  std::string fileName,
@@ -21,12 +25,20 @@
     if (fileName.empty())
     {
         log<level::ERR>("Error FileName is empty");
+        elog<InvalidArgument>(xyz::openbmc_project::Common::InvalidArgument::
+                              ARGUMENT_NAME("FileName"),
+                              xyz::openbmc_project::Common::InvalidArgument::
+                              ARGUMENT_VALUE(fileName.c_str()));
         return;
     }
 
     if (serverAddress.empty())
     {
         log<level::ERR>("Error ServerAddress is empty");
+        elog<InvalidArgument>(xyz::openbmc_project::Common::InvalidArgument::
+                              ARGUMENT_NAME("ServerAddress"),
+                              xyz::openbmc_project::Common::InvalidArgument::
+                              ARGUMENT_VALUE(serverAddress.c_str()));
         return;
     }
 
@@ -44,10 +56,12 @@
                                             fileName).c_str(), (char*)0);
         // execl only returns on fail
         log<level::ERR>("Error occurred during the TFTP call");
+        elog<InternalFailure>();
     }
     else if (pid < 0)
     {
         log<level::ERR>("Error occurred during fork");
+        elog<InternalFailure>();
     }
 
     return;