json/except: use a human readable key_error message
the exception string was completely useless without mentioning "you tried to dereference an invalid key".
This commit is contained in:
parent
6e533e47b7
commit
10e0c4f923
@ -16,6 +16,8 @@
|
||||
|
||||
#include "except.hpp"
|
||||
|
||||
#include "../format.hpp"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
json::parse_error::parse_error (const std::string &_what, size_t _line):
|
||||
@ -34,6 +36,7 @@ json::parse_error::what (void) const noexcept
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
json::key_error::key_error (std::string _what):
|
||||
error (std::move (_what))
|
||||
json::key_error::key_error (std::string _key):
|
||||
error (util::format::render ("missing key '%s'", _key)),
|
||||
key (_key)
|
||||
{ ; }
|
||||
|
@ -54,6 +54,8 @@ namespace json {
|
||||
/// Exception class for invalid object indexing
|
||||
struct key_error : public error {
|
||||
explicit key_error (std::string);
|
||||
|
||||
std::string key;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user