tlbmc: Use non-throwing filesystem APIs in store_impl Google-Bug-Id:478925741 PiperOrigin-RevId: 979543134 Change-Id: Ie689cde9c4bdc348aed7d753cec119b619c71b76
diff --git a/tlbmc/store/store_impl.cc b/tlbmc/store/store_impl.cc index f793a18..9bf1c73 100644 --- a/tlbmc/store/store_impl.cc +++ b/tlbmc/store/store_impl.cc
@@ -9,6 +9,7 @@ #include <optional> #include <ostream> #include <string> +#include <system_error> // NOLINT #include <utility> #include <vector> @@ -920,7 +921,12 @@ LOG(ERROR) << "The cached FRU table will be deleted."; // If Store is bad, then cache may be bad too. Let cache reload on next // boot. - std::filesystem::remove(fru_collector_options.cached_fru_table_path); + std::error_code ec; + if (!std::filesystem::remove(fru_collector_options.cached_fru_table_path, + ec) && + ec) { + LOG(WARNING) << "Failed to remove cached FRU table: " << ec.message(); + } return entity_config.status(); } @@ -981,7 +987,12 @@ LOG(ERROR) << "The cached FRU table will be deleted."; // If Store is bad, then cache may be bad too. Let cache reload on next // boot. - std::filesystem::remove(fru_collector_options.cached_fru_table_path); + std::error_code ec; + if (!std::filesystem::remove( + fru_collector_options.cached_fru_table_path, ec) && + ec) { + LOG(WARNING) << "Failed to remove cached FRU table: " << ec.message(); + } return sensor_collector.status(); }