From: Changgyu Choi Date: Mon, 27 Mar 2023 05:43:29 +0000 (+0900) Subject: Add create_directories() exception handling X-Git-Tag: accepted/tizen/unified/20230329.013224~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F67%2F290467%2F5;p=platform%2Fcore%2Fappfw%2Flaunchpad.git Add create_directories() exception handling std::filesystem::create_directories() can throw an exception. This patch adds the exception handling for the above case. Change-Id: I37228b7b38ae1c9894ae2b1586429c39e8379e63 Signed-off-by: Changgyu Choi --- diff --git a/src/launchpad-process-pool/file_monitor.cc b/src/launchpad-process-pool/file_monitor.cc index 01d0e1f..27c9d80 100644 --- a/src/launchpad-process-pool/file_monitor.cc +++ b/src/launchpad-process-pool/file_monitor.cc @@ -55,8 +55,15 @@ FileMonitor::FileMonitor(const std::string_view file_path, parent_path_ = path.parent_path(); file_name_ = path.filename(); if (!fs::exists(parent_path_)) { - if (!fs::create_directories(parent_path_)) { - _E("Failed to create directory. %s", parent_path_.c_str()); + try { + if (!fs::create_directories(parent_path_)) { + _E("Failed to create directory. %s", parent_path_.c_str()); + disposed_ = true; + return; + } + } catch (const std::exception& e) { + _E("Exception has been occurred: %s", e.what()); + disposed_ = true; return; } }