Skip to content

Commit

Permalink
Add missing files in exception message (#5360)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgugliel authored Aug 22, 2022
1 parent 7f014bd commit e3c7995
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions include/storage/io_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct IOConfig
}

bool IsValid() const;
std::vector<std::string> GetMissingFiles() const;
boost::filesystem::path GetPath(const std::string &fileName) const
{
if (!IsConfigured(fileName, required_input_files) &&
Expand Down
9 changes: 7 additions & 2 deletions src/osrm/osrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "engine/engine_config.hpp"
#include "engine/status.hpp"

#include <boost/algorithm/string/join.hpp>

#include <memory>

namespace osrm
Expand All @@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/storage/io_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -26,5 +27,18 @@ bool IOConfig::IsValid() const
}
return success;
}

std::vector<std::string> IOConfig::GetMissingFiles() const
{
std::vector<std::string> 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

0 comments on commit e3c7995

Please sign in to comment.