Print diagnostic information to avoid boost cryptic errors

This commit is contained in:
Michael Krasnyk 2017-05-05 08:30:36 +02:00 committed by Patrick Niklaus
parent e92967167f
commit 669ac058b8

View File

@ -10,6 +10,7 @@
#include <tbb/parallel_for.h>
#include <tbb/spin_mutex.h>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/iostreams/device/mapped_file.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
@ -91,6 +92,8 @@ template <typename Key, typename Value> struct CSVFilesParser
private:
// Parse a single CSV file and return result as a vector<Key, Value>
auto ParseCSVFile(const std::string &filename, std::size_t file_id) const
{
try
{
boost::iostreams::mapped_file_source mmap(filename);
auto first = mmap.begin(), last = mmap.end();
@ -119,6 +122,13 @@ template <typename Key, typename Value> struct CSVFilesParser
return std::move(result);
}
catch (const boost::exception& e)
{
const auto message = boost::format("exception in loading %1%:\n %2%") %
filename % boost::diagnostic_information(e);
throw util::exception(message.str() + SOURCE_REF);
}
}
const std::size_t start_index;
const KeyRule key_rule;