diff --git a/json/except.cpp b/json/except.cpp index 2892a1b5..3bb1ac19 100644 --- a/json/except.cpp +++ b/json/except.cpp @@ -17,14 +17,23 @@ #include "except.hpp" -//----------------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////////////// json::parse_error::parse_error (const std::string &_what, size_t _line): error (_what), - line (_line) + line (_line), + desc (_what + " at line " + std::to_string (_line)) { ; } //----------------------------------------------------------------------------- +const char* +json::parse_error::what (void) const noexcept +{ + return desc.c_str (); +} + + +/////////////////////////////////////////////////////////////////////////////// json::key_error::key_error (std::string _what): error (std::move (_what)) { ; } diff --git a/json/except.hpp b/json/except.hpp index d9004789..b795cc53 100644 --- a/json/except.hpp +++ b/json/except.hpp @@ -40,7 +40,10 @@ namespace json { explicit parse_error (const std::string &_what, size_t _line = 0); + const char* what (void) const noexcept override; + size_t line; + std::string desc; };