MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / exception_message

Method exception_message

lesson6-Segmentation/json.hpp:10572–10599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10570 }
10571
10572 std::string exception_message(const token_type expected, const std::string& context)
10573 {
10574 std::string error_msg = "syntax error ";
10575
10576 if (!context.empty())
10577 {
10578 error_msg += "while parsing " + context + " ";
10579 }
10580
10581 error_msg += "- ";
10582
10583 if (last_token == token_type::parse_error)
10584 {
10585 error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" +
10586 m_lexer.get_token_string() + "'";
10587 }
10588 else
10589 {
10590 error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token));
10591 }
10592
10593 if (expected != token_type::uninitialized)
10594 {
10595 error_msg += "; expected " + std::string(lexer_t::token_type_name(expected));
10596 }
10597
10598 return error_msg;
10599 }
10600
10601 private:
10602 /// callback function

Callers

nothing calls this directly

Calls 2

get_token_stringMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected