From d9157743d2769aeac62a97c47ebf45493271c21e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 6 Mar 2020 18:12:10 +0300 Subject: Add UTF-8 validation error details to diagnostics --- bdep/ci-parsers.cxx | 8 +++----- bdep/utility.cxx | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/bdep/ci-parsers.cxx b/bdep/ci-parsers.cxx index efee55c..7cf8d62 100644 --- a/bdep/ci-parsers.cxx +++ b/bdep/ci-parsers.cxx @@ -39,11 +39,9 @@ namespace bdep // auto validate_value = [&o, &v] () { - if (!utf8 (v, codepoint_types::graphic)) - throw invalid_value (o, - v, - "not UTF-8 encoded or contains non-graphic " - "Unicode codepoints"); + string what; + if (!utf8 (v, what, codepoint_types::graphic)) + throw invalid_value (o, v, what); }; if (o == "--build-email") diff --git a/bdep/utility.cxx b/bdep/utility.cxx index 8821790..0e19691 100644 --- a/bdep/utility.cxx +++ b/bdep/utility.cxx @@ -300,11 +300,11 @@ namespace bdep void validate_utf8_graphic (const string& s, const char* what, const char* opt) { - if (!utf8 (s, codepoint_types::graphic)) + string ed; + if (!utf8 (s, ed, codepoint_types::graphic)) { diag_record dr (fail); - dr << what << " '" << s << "' is not UTF-8 encoded or contains " - << "non-graphic Unicode codepoints"; + dr << "invalid " << what << " '" << s << "': " << ed; if (opt != nullptr) dr << info << "consider using " << opt << " to override"; -- cgit v1.1