From bc9b0e990ce7ea58598c7eaaf3207cb15a8bec14 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 27 Sep 2017 18:28:07 -0700 Subject: [PATCH] ircd::json: Simplify expectation error message. --- ircd/json.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ircd/json.cc b/ircd/json.cc index a0447d5f2..4cbf50586 100644 --- a/ircd/json.cc +++ b/ircd/json.cc @@ -605,9 +605,11 @@ catch(const qi::expectation_failure &e) { const auto rule(ircd::string(e.what_)); const long size(std::distance(e.first, e.last)); - throw parse_error("Expected JSON %s. You input %zu invalid characters starting with `%s`.", + const long cat(std::distance(start, e.first)); + throw parse_error("Expected %s. You input %zd invalid characters at position %zd: %s", between(rule, "<", ">"), size, + cat, string_view(e.first, e.first + std::min(size, 64L))); } @@ -647,9 +649,11 @@ catch(const qi::expectation_failure &e) { const auto rule(ircd::string(e.what_)); const long size(std::distance(e.first, e.last)); - throw parse_error("Expected JSON %s. You input %zu invalid characters starting with `%s`.", + const long cat(std::distance(string_view::data(), e.first)); + throw parse_error("Expected %s. You input %zd invalid characters at position %zd: %s.", between(rule, "<", ">"), size, + cat, string_view(e.first, e.first + std::min(size, 64L))); }