feat: improve error messages
This commit is contained in:
parent
531c918ba5
commit
55ad862ba4
|
@ -5,7 +5,9 @@
|
|||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/directory.hpp>
|
||||
#include <boost/filesystem/exception.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
|
@ -21,6 +23,7 @@ Mappings Mappings::load() {
|
|||
|
||||
// load mappings
|
||||
fs::directory_iterator end_itr;
|
||||
try {
|
||||
for (fs::directory_iterator itr("mappings"); itr != end_itr; ++itr) {
|
||||
if (fs::is_directory(itr->status()) ||
|
||||
!boost::algorithm::ends_with(itr->path().string(), ".csv"))
|
||||
|
@ -38,6 +41,13 @@ Mappings Mappings::load() {
|
|||
l.size() >= 4 ? std::optional(l[3]) : std::nullopt};
|
||||
}
|
||||
}
|
||||
} catch (boost::filesystem::filesystem_error &e) {
|
||||
if (e.code() == boost::system::errc::no_such_file_or_directory) {
|
||||
throw std::runtime_error(
|
||||
std::string("The mappings directory is missing!\n") + e.what());
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
if (fs::is_regular_file("renames.csv")) {
|
||||
csv::CsvReader csv("renames.csv");
|
||||
|
@ -51,6 +61,8 @@ Mappings Mappings::load() {
|
|||
|
||||
renames[l[0]] = l[1];
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(warning) << "no renames found, skipping";
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "loaded " << mappings.size() << " mappings and "
|
||||
|
|
Loading…
Reference in a new issue