diff --git a/include/mapnik/json/error_handler.hpp b/include/mapnik/json/error_handler.hpp index 78ae5ebb6..c3a7a69b4 100644 --- a/include/mapnik/json/error_handler.hpp +++ b/include/mapnik/json/error_handler.hpp @@ -23,34 +23,42 @@ #ifndef MAPNIK_JSON_ERROR_HANDLER_HPP #define MAPNIK_JSON_ERROR_HANDLER_HPP -#include -#include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" +#include #include #pragma GCC diagnostic pop +// mapnik +#include +// stl #include +#include +#include + namespace mapnik { namespace json { template struct error_handler { - using result_type = void; - void operator() ( + using result_type = boost::spirit::qi::error_handler_result; + result_type operator() ( Iterator, Iterator end, Iterator err_pos, boost::spirit::info const& what) const { +#ifdef MAPNIK_LOG std::stringstream s; using difference_type = typename std::iterator_traits::difference_type; - auto start_err= err_pos; + auto start_err = err_pos; std::advance(err_pos, std::min(std::distance(err_pos, end), difference_type(16))); auto end_err = err_pos; assert(end_err <= end); s << "Mapnik GeoJSON parsing error:" << what << " expected but got: " << std::string(start_err, end_err); - throw std::runtime_error(s.str()); + MAPNIK_LOG_ERROR(error_handler) << s.str(); +#endif + return boost::spirit::qi::fail; } };