diff --git a/src/json.hpp b/src/json.hpp index 3fedc045..5a9399fd 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -11334,7 +11334,7 @@ basic_json_parser_74: // check if stream is still good 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'); diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 7e7e16e3..e2dd777b 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -10367,7 +10367,7 @@ class basic_json // check if stream is still good 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'); diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index ce984b0d..3f17a917 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -924,7 +924,8 @@ TEST_CASE("regression tests") 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") @@ -938,7 +939,8 @@ TEST_CASE("regression tests") 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"); } }