summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-07-01 16:49:22 +0000
committerGordon Sim <gsim@apache.org>2010-07-01 16:49:22 +0000
commitc54cd19d2d5b1e8ab5cc36ca7e1b1068b6ff7be2 (patch)
tree3f40bfadaed5cf72937b6a37ce63af9e66f549ca /cpp/src
parent21383bd52d2b2762dc4c0d09b52465cfa3856de4 (diff)
downloadqpid-python-c54cd19d2d5b1e8ab5cc36ca7e1b1068b6ff7be2.tar.gz
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
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp4
-rw-r--r--cpp/src/tests/MessagingSessionTests.cpp8
2 files changed, 12 insertions, 0 deletions
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()