🔨 added user-defined exception #493
Replaced old std::invalid_argument exception by parse_error.111 to have unified exceptions in case of input stream errors.
This commit is contained in:
parent
63c2c62f19
commit
1de80e8af4
3 changed files with 6 additions and 4 deletions
|
@ -11334,7 +11334,7 @@ basic_json_parser_74:
|
||||||
// check if stream is still good
|
// check if stream is still good
|
||||||
if (m_stream->fail())
|
if (m_stream->fail())
|
||||||
{
|
{
|
||||||
JSON_THROW(std::invalid_argument("stream error"));
|
JSON_THROW(parse_error(111, 0, "bad input stream"));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::getline(*m_stream, m_line_buffer_tmp, '\n');
|
std::getline(*m_stream, m_line_buffer_tmp, '\n');
|
||||||
|
|
|
@ -10367,7 +10367,7 @@ class basic_json
|
||||||
// check if stream is still good
|
// check if stream is still good
|
||||||
if (m_stream->fail())
|
if (m_stream->fail())
|
||||||
{
|
{
|
||||||
JSON_THROW(std::invalid_argument("stream error"));
|
JSON_THROW(parse_error(111, 0, "bad input stream"));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::getline(*m_stream, m_line_buffer_tmp, '\n');
|
std::getline(*m_stream, m_line_buffer_tmp, '\n');
|
||||||
|
|
|
@ -924,7 +924,8 @@ TEST_CASE("regression tests")
|
||||||
|
|
||||||
l.m_stream->setstate(std::ios_base::failbit);
|
l.m_stream->setstate(std::ios_base::failbit);
|
||||||
|
|
||||||
CHECK_THROWS_AS(l.fill_line_buffer(), std::invalid_argument);
|
CHECK_THROWS_AS(l.fill_line_buffer(), json::parse_error);
|
||||||
|
CHECK_THROWS_WITH(l.fill_line_buffer(), "[json.exception.parse_error.111] parse error: bad input stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("setting badbit")
|
SECTION("setting badbit")
|
||||||
|
@ -938,7 +939,8 @@ TEST_CASE("regression tests")
|
||||||
|
|
||||||
l.m_stream->setstate(std::ios_base::badbit);
|
l.m_stream->setstate(std::ios_base::badbit);
|
||||||
|
|
||||||
CHECK_THROWS_AS(l.fill_line_buffer(), std::invalid_argument);
|
CHECK_THROWS_AS(l.fill_line_buffer(), json::parse_error);
|
||||||
|
CHECK_THROWS_WITH(l.fill_line_buffer(), "[json.exception.parse_error.111] parse error: bad input stream");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue