Skip to content

Commit

Permalink
Skip category check for unknown ODBC errors in "Reconnect" test
Browse files Browse the repository at this point in the history
At least PostgreSQL ODBC driver just returns "HY000", i.e. "General
error" in case of connection loss, which clearly can't be always mapped
to soci_error::connection_error, so we need to take into account that
get_error_category() doesn't always return the expected value, at least
with the ODBC backend.
  • Loading branch information
vadz committed Oct 12, 2020
1 parent 0d014a9 commit 0d6ab16
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/common-tests.h
Expand Up @@ -4667,8 +4667,17 @@ TEST_CASE_METHOD(common_tests, "Reconnect", "[keep-alive][.]")
}
catch (soci_error const& e)
{
INFO( "Exception message: " << e.what() );
CHECK( e.get_error_category() == soci_error::connection_error );
if ( sql.get_backend_name() == "odbc" ||
e.get_error_category() == soci_error::unknown )
{
WARN( "Skipping error check because ODBC driver returned "
"unknown error: " << e.what() );
}
else
{
INFO( "Exception message: " << e.what() );
CHECK( e.get_error_category() == soci_error::connection_error );
}
}

std::cout << "Please undo the previous action "
Expand Down

0 comments on commit 0d6ab16

Please sign in to comment.