From e3c7995b00409f3da335300f7ca3d212a69602a4 Mon Sep 17 00:00:00 2001 From: Rafael Guglielmetti Date: Mon, 22 Aug 2022 08:32:25 +0200 Subject: [PATCH] Add missing files in exception message (#5360) --- CHANGELOG.md | 1 + include/storage/io_config.hpp | 1 + src/osrm/osrm.cpp | 9 +++++++-- src/storage/io_config.cpp | 18 ++++++++++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d9c9d58f..ed93059d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - FIXED: Use Boost.Beast to parse HTTP request. [#6294](https://github.com/Project-OSRM/osrm-backend/pull/6294) - FIXED: Fix inefficient osrm-routed connection handling [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113) - Misc: + - CHANGED: missing files list is included in exception message. [#5360](https://github.com/Project-OSRM/osrm-backend/pull/5360) - CHANGED: Do not use deprecated Callback::Call overload in Node bindings. [#6318](https://github.com/Project-OSRM/osrm-backend/pull/6318) - FIXED: Fix distance calculation consistency. [#6315](https://github.com/Project-OSRM/osrm-backend/pull/6315) - FIXED: Fix performance issue after migration to sol2 3.3.0. [#6304](https://github.com/Project-OSRM/osrm-backend/pull/6304) diff --git a/include/storage/io_config.hpp b/include/storage/io_config.hpp index 577291ee1..831382df7 100644 --- a/include/storage/io_config.hpp +++ b/include/storage/io_config.hpp @@ -25,6 +25,7 @@ struct IOConfig } bool IsValid() const; + std::vector GetMissingFiles() const; boost::filesystem::path GetPath(const std::string &fileName) const { if (!IsConfigured(fileName, required_input_files) && diff --git a/src/osrm/osrm.cpp b/src/osrm/osrm.cpp index 8871aff45..83e1076f7 100644 --- a/src/osrm/osrm.cpp +++ b/src/osrm/osrm.cpp @@ -10,6 +10,8 @@ #include "engine/engine_config.hpp" #include "engine/status.hpp" +#include + #include namespace osrm @@ -25,8 +27,11 @@ OSRM::OSRM(engine::EngineConfig &config) // First, check that necessary core data is available if (!config.use_shared_memory && !config.storage_config.IsValid()) { - throw util::exception("Required files are missing, cannot continue. Have all the " - "pre-processing steps been run?"); + const auto &missingFiles = config.storage_config.GetMissingFiles(); + throw util::exception("Required files are missing, cannot continue. Have all the " + "pre-processing steps been run? " + "Missing files: " + + boost::algorithm::join(missingFiles, ", ")); } // Now, check that the algorithm requested can be used with the data diff --git a/src/storage/io_config.cpp b/src/storage/io_config.cpp index e100a9317..cd05d2d76 100644 --- a/src/storage/io_config.cpp +++ b/src/storage/io_config.cpp @@ -10,10 +10,11 @@ namespace osrm { namespace storage { + +namespace fs = boost::filesystem; + bool IOConfig::IsValid() const { - namespace fs = boost::filesystem; - bool success = true; for (auto &fileName : required_input_files) { @@ -26,5 +27,18 @@ bool IOConfig::IsValid() const } return success; } + +std::vector IOConfig::GetMissingFiles() const +{ + std::vector missingFiles; + for (auto &fileName : required_input_files) + { + if (!fs::is_regular_file(fs::path(base_path.string() + fileName.string()))) + { + missingFiles.push_back(base_path.string() + fileName.string()); + } + } + return missingFiles; +} } // namespace storage } // namespace osrm