json/except: add line number to what output

This commit is contained in:
Danny Robson 2015-09-09 18:38:54 +10:00
parent c4f773f129
commit 3801842373
2 changed files with 14 additions and 2 deletions

View File

@ -17,14 +17,23 @@
#include "except.hpp" #include "except.hpp"
//----------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////
json::parse_error::parse_error (const std::string &_what, size_t _line): json::parse_error::parse_error (const std::string &_what, size_t _line):
error (_what), 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): json::key_error::key_error (std::string _what):
error (std::move (_what)) error (std::move (_what))
{ ; } { ; }

View File

@ -40,7 +40,10 @@ namespace json {
explicit parse_error (const std::string &_what, size_t _line = 0); explicit parse_error (const std::string &_what, size_t _line = 0);
const char* what (void) const noexcept override;
size_t line; size_t line;
std::string desc;
}; };