diff --git a/include/ircd/json/json.h b/include/ircd/json/json.h index f32477862..cb584338f 100644 --- a/include/ircd/json/json.h +++ b/include/ircd/json/json.h @@ -21,7 +21,6 @@ namespace ircd::json IRCD_EXCEPTION(error, type_error); IRCD_EXCEPTION(error, not_found); IRCD_EXCEPTION(parse_error, recursion_limit); - struct expectation_failure; struct value; struct member; diff --git a/ircd/json.cc b/ircd/json.cc index 31a3e1ced..5151d82a8 100644 --- a/ircd/json.cc +++ b/ircd/json.cc @@ -21,6 +21,8 @@ namespace ircd::json // Instantiations of the grammars struct parser extern const parser; struct printer extern const printer; + + const size_t &error_show_max {48}; } BOOST_FUSION_ADAPT_STRUCT @@ -284,22 +286,6 @@ struct ircd::json::output } }; -struct ircd::json::expectation_failure -:parse_error -{ - expectation_failure(const char *const &start, - const qi::expectation_failure &e, - const ssize_t &show_max = 64) - :parse_error - { - "Expected %s. You input %zd invalid characters at position %zd: %s", - ircd::string(e.what_), - std::distance(e.first, e.last), - std::distance(start, e.first), - string_view{e.first, e.first + std::min(std::distance(e.first, e.last), show_max)} - }{} -}; - struct ircd::json::parser :input { @@ -1889,7 +1875,10 @@ try } catch(const qi::expectation_failure &e) { - throw expectation_failure(start, e); + throw expectation_failure + { + e, start, error_show_max + }; } ircd::json::vector::const_iterator @@ -1918,7 +1907,10 @@ const try } catch(const qi::expectation_failure &e) { - throw expectation_failure(string_view::begin(), e); + throw expectation_failure + { + e, string_view::data(), error_show_max + }; } ircd::json::vector::const_iterator @@ -2151,7 +2143,10 @@ const try } catch(const qi::expectation_failure &e) { - throw expectation_failure(string_view::begin(), e); + throw expectation_failure + { + e, string_view::begin(), error_show_max + }; } ircd::json::object::const_iterator @@ -2229,7 +2224,10 @@ try } catch(const qi::expectation_failure &e) { - throw expectation_failure(start, e); + throw expectation_failure + { + e, start, error_show_max + }; } // @@ -2525,7 +2523,10 @@ const try } catch(const qi::expectation_failure &e) { - throw expectation_failure(string_view::begin(), e); + throw expectation_failure + { + e, string_view::data(), error_show_max + }; } ircd::json::array::const_iterator @@ -2625,7 +2626,10 @@ try } catch(const qi::expectation_failure &e) { - throw expectation_failure(start, e); + throw expectation_failure + { + e, start, error_show_max + }; } bool @@ -3737,7 +3741,7 @@ try valid(s); return {}; } -catch(const expectation_failure &e) +catch(const std::exception &e) { return e.what(); } @@ -3774,7 +3778,10 @@ try } catch(const qi::expectation_failure &e) { - throw expectation_failure(begin(s), e); + throw expectation_failure + { + e, begin(s), error_show_max + }; } void