Fix the core dump by using filesystem error_code

The currently used filesystem method will cause an exception if the
file system is damaged for some reason, resulting in a core dump of
the process.
So the overloaded method with the error_code parameter should be used
here to ensure that the process core dump will not be caused after an
exception is thrown.

Fixes: openbmc/phosphor-bmc-code-mgmt#12

Tested: built phosphor-bmc-code-mgmt successfully and CI passes.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I329f78b481cb466e755bc1b78562583620f561c2
diff --git a/download_manager.cpp b/download_manager.cpp
index 972278b..fdffcb9 100644
--- a/download_manager.cpp
+++ b/download_manager.cpp
@@ -15,6 +15,7 @@
 #include <filesystem>
 #include <iostream>
 #include <string>
+#include <system_error>
 
 namespace phosphor
 {
@@ -61,9 +62,11 @@
 
     // Check if IMAGE DIR exists
     fs::path imgDirPath(IMG_UPLOAD_DIR);
-    if (!fs::is_directory(imgDirPath))
+    std::error_code ec;
+    if (!fs::is_directory(imgDirPath, ec))
     {
-        error("Image Dir {PATH} does not exist", "PATH", imgDirPath);
+        error("Image Dir {PATH} does not exist: {ERROR_MSG}", "PATH",
+              imgDirPath, "ERROR_MSG", ec.message());
         elog<InternalFailure>();
         return;
     }