Apply feedback, add boost version check

This commit is contained in:
Jordan Bayles 2020-11-08 19:54:53 -08:00
parent 8f6f9b6a80
commit b8e9581057
2 changed files with 11 additions and 0 deletions

View File

@ -30,6 +30,10 @@ inline bool loadDocument(const std::string &path, nlohmann::json &document)
}
#else
document = nlohmann::json::parse(file, nullptr, false);
if (document.is_discarded()) {
std::cerr << "nlohmann::json failed to parse the document.";
return false;
}
#endif
return true;

View File

@ -14,7 +14,12 @@
# include <boost/property_tree/json_parser.hpp>
#endif
// Source locations were added in boost 1.73.
#include <boost/version.hpp>
#if (BOOST_VERSION > 107300)
#include <boost/assert/source_location.hpp>
#endif
#include <boost/config/detail/suffix.hpp>
#include <valijson/utils/file_utils.hpp>
#include <valijson/exceptions.hpp>
@ -29,9 +34,11 @@ BOOST_NORETURN void throw_exception(std::exception const & e ) {
valijson::throwRuntimeError(e.what());
}
#if (BOOST_VERSION > 107300)
BOOST_NORETURN void throw_exception(std::exception const & e, boost::source_location const & loc ) {
valijson::throwRuntimeError(e.what());
}
#endif
} // namespace boost