foonathan/lexy

Is there an easy way to get an error-string from a lexy::parse call?

Cthaeeh opened this issue · 0 comments

E.g.

std::expected<X, std::string> parseX(
      const std::string &str)
{
    auto result = lexy::parse<grammar::Table>(lexy::string_input(str),
                                              lexy_ext::report_error);

    if (result.is_success()) {
        return result.value();
    } else {
        return std::unexpected( ? ); //<-
    }
}

Or do I have to implement my own lexy_ext::report_error in some form?