summaryrefslogtreecommitdiff
path: root/qpid/cpp
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
commitcd8ce28d8fd26c434d69ea949167b7e56418246f (patch)
tree17c87f0e73dc7d7cb75635ce27702fb1e99dc6a3 /qpid/cpp
parent2b74ca3397532015562f882c948eabcad812427c (diff)
downloadqpid-python-cd8ce28d8fd26c434d69ea949167b7e56418246f.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@959721 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp4
-rw-r--r--qpid/cpp/src/tests/MessagingSessionTests.cpp8
2 files changed, 12 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp b/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp
index 2fe55cc035..f3cc4f7cc1 100644
--- a/qpid/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp
+++ b/qpid/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/qpid/cpp/src/tests/MessagingSessionTests.cpp b/qpid/cpp/src/tests/MessagingSessionTests.cpp
index ce1d885e46..a23e8c3a9e 100644
--- a/qpid/cpp/src/tests/MessagingSessionTests.cpp
+++ b/qpid/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()