Use and extend the detail helpers to remove duplicated code
Library: - binary_reader: format bytes with hex_byte() instead of snprintf - add throw_type_must_be() for the 20 copies of type_error.302 - binary_reader: add last_byte_error()/unexpected_byte() for the 32 "parse error at the last read byte" sites (replaces bon8_error) - json_sax: add check_container_size() for out_of_range.408 and diagnostic_positions::set_container_start/_end() - json_pointer: add throw_no_parent() (405) and throw_unresolved() (404) Tests: - unit-class_parser uses the shared utils::SaxCountdown - move SaxEventLogger (and its ExitAfter* variants) from unit-class_parser and unit-deserialization into the new tests/src/test_sax.hpp Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
11 files changed
+544
-711
No files matched your search
@@ -3266,7 +3266,7 @@ public:
|
||||
{
|
||||
if (!is_binary())
|
||||
{
|
||||
JSON_THROW(type_error::create(302, detail::concat("type must be binary, but is ", type_name()), this));
|
||||
detail::throw_type_must_be("binary", *this);
|
||||
}
|
||||
|
||||
return *get_ptr<binary_t*>();
|
||||
@@ -3278,7 +3278,7 @@ public:
|
||||
{
|
||||
if (!is_binary())
|
||||
{
|
||||
JSON_THROW(type_error::create(302, detail::concat("type must be binary, but is ", type_name()), this));
|
||||
detail::throw_type_must_be("binary", *this);
|
||||
}
|
||||
|
||||
return *get_ptr<const binary_t*>();
|
||||
|
||||
Reference in new issue
Block a user