From afd243cc87827c94f0cea73748ffc5c1fdf1880a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 12 Jun 2021 20:54:28 +0100 Subject: Avoid direct use of runtime_error in PostgreSQL stuff Adds proper exception which extends it and gets the PostgreSQL error message. --- test/test-postgresql.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test-postgresql.cpp b/test/test-postgresql.cpp index 3a12f43..eaf6d58 100644 --- a/test/test-postgresql.cpp +++ b/test/test-postgresql.cpp @@ -22,11 +22,11 @@ BOOST_AUTO_TEST_CASE(simple) BOOST_CHECK_THROW(([]() { MyGrate::Output::Pq::PqConn {"nonsense"}; }()), - std::runtime_error); + MyGrate::Output::Pq::PqErr); MyGrate::Output::Pq::PqConn c {CONNSTR}; BOOST_CHECK_NO_THROW(c.query("SET application_name = ''")); BOOST_CHECK_NO_THROW(c.query("SET application_name = 'something'")); - BOOST_CHECK_THROW(c.query("SET application_name = "), std::runtime_error); + BOOST_CHECK_THROW(c.query("SET application_name = "), MyGrate::Output::Pq::PqErr); // BOOST_CHECK_THROW(c.query("SET application_name = $1", {}), std::logic_error); BOOST_CHECK_NO_THROW(c.query("SET application_name = 'something'", {})); c.query("DROP TABLE IF EXISTS test"); @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(simple) BOOST_CHECK_NO_THROW(c.query("INSERT INTO test VALUES($1)", {"string_view"})); BOOST_CHECK_NO_THROW(c.query("INSERT INTO test VALUES($1)", {nullptr})); BOOST_CHECK_NO_THROW(c.query("INSERT INTO test VALUES($1)", {1.2})); - BOOST_CHECK_THROW(c.query("INSERT INTO test VALUES($1)", {MyGrate::Time {}}), std::runtime_error); + BOOST_CHECK_THROW(c.query("INSERT INTO test VALUES($1)", {MyGrate::Time {}}), std::logic_error); c.query("DROP TABLE test"); } -- cgit v1.2.3