Refactor logging, improve error handling workflow, clang-format. (#3385)

This commit is contained in:
Daniel Patterson
2016-12-06 12:30:46 -08:00
committed by GitHub
parent 6f4c6e84ae
commit 468d8c0031
62 changed files with 1778 additions and 1607 deletions
+15 -9
View File
@@ -1,7 +1,10 @@
#include "extractor/raster_source.hpp"
#include "util/simple_logger.hpp"
#include "util/exception.hpp"
#include "util/exception_utils.hpp"
#include "util/log.hpp"
#include "util/timing_util.hpp"
#include "util/typedefs.hpp"
#include <cmath>
@@ -92,20 +95,20 @@ int SourceContainer::LoadRasterSource(const std::string &path_string,
const auto itr = LoadedSourcePaths.find(path_string);
if (itr != LoadedSourcePaths.end())
{
util::SimpleLogger().Write() << "[source loader] Already loaded source '" << path_string
<< "' at source_id " << itr->second;
util::Log() << "[source loader] Already loaded source '" << path_string << "' at source_id "
<< itr->second;
return itr->second;
}
int source_id = static_cast<int>(LoadedSources.size());
util::SimpleLogger().Write() << "[source loader] Loading from " << path_string << " ... ";
util::Log() << "[source loader] Loading from " << path_string << " ... ";
TIMER_START(loading_source);
boost::filesystem::path filepath(path_string);
if (!boost::filesystem::exists(filepath))
{
throw util::exception("error reading: no such path");
throw util::exception(path_string + " does not exist" + SOURCE_REF);
}
RasterGrid rasterData{filepath, ncols, nrows};
@@ -115,8 +118,7 @@ int SourceContainer::LoadRasterSource(const std::string &path_string,
LoadedSourcePaths.emplace(path_string, source_id);
LoadedSources.push_back(std::move(source));
util::SimpleLogger().Write() << "[source loader] ok, after " << TIMER_SEC(loading_source)
<< "s";
util::Log() << "[source loader] ok, after " << TIMER_SEC(loading_source) << "s";
return source_id;
}
@@ -126,7 +128,9 @@ RasterDatum SourceContainer::GetRasterDataFromSource(unsigned int source_id, dou
{
if (LoadedSources.size() < source_id + 1)
{
throw util::exception("error reading: no such loaded source");
throw util::exception("Attempted to access source " + std::to_string(source_id) +
", but there are only " + std::to_string(LoadedSources.size()) +
" loaded" + SOURCE_REF);
}
BOOST_ASSERT(lat < 90);
@@ -145,7 +149,9 @@ SourceContainer::GetRasterInterpolateFromSource(unsigned int source_id, double l
{
if (LoadedSources.size() < source_id + 1)
{
throw util::exception("error reading: no such loaded source");
throw util::exception("Attempted to access source " + std::to_string(source_id) +
", but there are only " + std::to_string(LoadedSources.size()) +
" loaded" + SOURCE_REF);
}
BOOST_ASSERT(lat < 90);