👌 apply review comment
This commit is contained in:
parent
cca872f18f
commit
432d78195d
@ -64,6 +64,10 @@ Whether the input is valid JSON.
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Exceptions
|
||||
|
||||
Throws [`parse_error.116`](../../home/exceptions.md#jsonexceptionparse_error116) if passed `#!cpp FILE` pointer is `#!cpp nullptr`.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the length of the input. The parser is a predictive LL(1) parser.
|
||||
|
||||
@ -28,7 +28,7 @@ static basic_json parse(IteratorType first, IteratorType last,
|
||||
: A compatible input, for instance:
|
||||
|
||||
- an `std::istream` object
|
||||
- a `FILE` pointer (will throw [json.exception.parse_error.116](../../home/exceptions.md#jsonexceptionparse_error116) if passed pointer is `#!cpp nullptr`)
|
||||
- a `FILE` pointer
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- a `std::string`
|
||||
@ -71,6 +71,14 @@ Deserialized JSON value; in case of a parse error and `allow_exceptions` set to
|
||||
|
||||
Strong guarantee: if an exception is thrown, there are no changes in the JSON value.
|
||||
|
||||
## Exceptions
|
||||
|
||||
- Throws [`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101) in case of an unexpected token.
|
||||
- Throws [`parse_error.102`](../../home/exceptions.md#jsonexceptionparse_error102) if to_unicode fails or surrogate
|
||||
error.
|
||||
- Throws [`parse_error.103`](../../home/exceptions.md#jsonexceptionparse_error103) if to_unicode fails.
|
||||
- Throws [`parse_error.116`](../../home/exceptions.md#jsonexceptionparse_error116) if passed `#!cpp FILE` pointer is `#!cpp nullptr`.
|
||||
|
||||
## Complexity
|
||||
|
||||
Linear in the length of the input. The parser is a predictive LL(1) parser. The complexity can be higher if the parser
|
||||
|
||||
@ -361,7 +361,7 @@ A `#!cpp FILE*` pointer passed to the [parse](../api/basic_json/parse.md) functi
|
||||
!!! failure "Example message"
|
||||
|
||||
```
|
||||
[json.exception.parse_error.116] parse error: input file is invalid: No such file or directory
|
||||
[json.exception.parse_error.116] parse error: input file is invalid
|
||||
```
|
||||
|
||||
## Iterator errors
|
||||
|
||||
@ -9,9 +9,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <array> // array
|
||||
#include <cerrno> // errno
|
||||
#include <cstddef> // size_t
|
||||
#include <cstring> // strlen, strerror
|
||||
#include <cstring> // strlen
|
||||
#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
|
||||
#include <memory> // shared_ptr, make_shared, addressof
|
||||
#include <numeric> // accumulate
|
||||
@ -55,7 +54,7 @@ class file_input_adapter
|
||||
{
|
||||
if (m_file == nullptr)
|
||||
{
|
||||
JSON_THROW(parse_error::create(116, 0, detail::concat("input file is invalid: ", reinterpret_cast<const char*>(std::strerror(errno))), nullptr));
|
||||
JSON_THROW(parse_error::create(116, 0, "input file is invalid", nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5893,9 +5893,8 @@ std::size_t hash(const BasicJsonType& j)
|
||||
|
||||
|
||||
#include <array> // array
|
||||
#include <cerrno> // errno
|
||||
#include <cstddef> // size_t
|
||||
#include <cstring> // strlen, strerror
|
||||
#include <cstring> // strlen
|
||||
#include <iterator> // begin, end, iterator_traits, random_access_iterator_tag, distance, next
|
||||
#include <memory> // shared_ptr, make_shared, addressof
|
||||
#include <numeric> // accumulate
|
||||
@ -5942,7 +5941,7 @@ class file_input_adapter
|
||||
{
|
||||
if (m_file == nullptr)
|
||||
{
|
||||
JSON_THROW(parse_error::create(116, 0, detail::concat("input file is invalid: ", reinterpret_cast<const char*>(std::strerror(errno))), nullptr));
|
||||
JSON_THROW(parse_error::create(116, 0, "input file is invalid", nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -335,9 +335,10 @@ TEST_CASE("deserialization")
|
||||
|
||||
SECTION("FILE*")
|
||||
{
|
||||
std::FILE* f = std::fopen("nonexisting_file", "r"); // NOTLINT(cppcoreguidelines-owning-memory)
|
||||
std::FILE* f = std::fopen("nonexisting_file", "r"); // NOLINT(cppcoreguidelines-owning-memory)
|
||||
json _;
|
||||
CHECK_THROWS_WITH_AS(_ = json::parse(f), "[json.exception.parse_error.116] parse error: input file is invalid: No such file or directory", json::parse_error&);
|
||||
CHECK_THROWS_WITH_AS(_ = json::parse(f), "[json.exception.parse_error.116] parse error: input file is invalid", json::parse_error&);
|
||||
CHECK_THROWS_WITH_AS(_ = json::accept(f), "[json.exception.parse_error.116] parse error: input file is invalid", json::parse_error&);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user