Show full text in tagged_text parse error

This commit is contained in:
Nikita Lisitsa 2023-01-05 19:12:35 +03:00
parent 2906e31634
commit b9939ba10e
2 changed files with 4 additions and 4 deletions

View file

@ -33,7 +33,7 @@ namespace psemek::ui
struct parse_error struct parse_error
: std::runtime_error : std::runtime_error
{ {
parse_error(std::string error, std::size_t position); parse_error(std::string error, std::size_t position, std::string text);
std::size_t position() const noexcept { return position_; } std::size_t position() const noexcept { return position_; }

View file

@ -4,8 +4,8 @@
namespace psemek::ui namespace psemek::ui
{ {
tagged_text::parse_error::parse_error(std::string error, std::size_t position) tagged_text::parse_error::parse_error(std::string error, std::size_t position, std::string text)
: std::runtime_error(std::move(error) + util::to_string(" at symbol ", position)) : std::runtime_error(std::move(error) + util::to_string(" at symbol ", position, ", full text: \"", text, "\""))
, position_(position) , position_(position)
{} {}
@ -17,7 +17,7 @@ namespace psemek::ui
auto error = [&](std::string message) auto error = [&](std::string message)
{ {
throw parse_error(message, current - text.begin()); throw parse_error(message, current - text.begin(), std::string(text));
}; };
bool in_tag = false; bool in_tag = false;