From c54cd19d2d5b1e8ab5cc36ca7e1b1068b6ff7be2 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 1 Jul 2010 16:49:22 +0000 Subject: QPID-664: Translate exceptions to correct type when occuring on creating new session. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@959721 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp | 4 ++++ cpp/src/tests/MessagingSessionTests.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'cpp') diff --git a/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp b/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp index 2fe55cc035..f3cc4f7cc1 100644 --- a/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp @@ -213,6 +213,10 @@ qpid::messaging::Session ConnectionImpl::newSession(bool transactional, const st break; } catch (const qpid::TransportFailure&) { open(); + } catch (const qpid::SessionException& e) { + throw qpid::messaging::SessionError(e.what()); + } catch (const std::exception& e) { + throw qpid::messaging::MessagingException(e.what()); } } return impl; diff --git a/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp index ce1d885e46..a23e8c3a9e 100644 --- a/cpp/src/tests/MessagingSessionTests.cpp +++ b/cpp/src/tests/MessagingSessionTests.cpp @@ -775,6 +775,14 @@ QPID_AUTO_TEST_CASE(testAuthenticatedUsername) BOOST_CHECK_EQUAL(fix.connection.getAuthenticatedUsername(), std::string("anonymous")); } +QPID_AUTO_TEST_CASE(testExceptionOnClosedConnection) +{ + MessagingFixture fix; + fix.connection.close(); + BOOST_CHECK_THROW(fix.connection.createSession(), MessagingException); + Connection connection("blah"); + BOOST_CHECK_THROW(connection.createSession(), MessagingException); +} QPID_AUTO_TEST_SUITE_END() -- cgit v1.2.1