You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2014/02/25 14:47:27 UTC

svn commit: r1571688 - in /qpid/trunk/qpid: cpp/src/qpid/messaging/amqp/ConnectionContext.cpp tests/src/py/qpid_tests/broker_0_10/new_api.py

Author: gsim
Date: Tue Feb 25 13:47:27 2014
New Revision: 1571688

URL: http://svn.apache.org/r1571688
Log:
QPID-5584: use more specific exception types where appropriate

Modified:
    qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp
    qpid/trunk/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp?rev=1571688&r1=1571687&r2=1571688&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp Tue Feb 25 13:47:27 2014
@@ -25,6 +25,7 @@
 #include "SenderContext.h"
 #include "SessionContext.h"
 #include "Transport.h"
+#include "qpid/amqp/descriptors.h"
 #include "qpid/messaging/exceptions.h"
 #include "qpid/messaging/AddressImpl.h"
 #include "qpid/messaging/Duration.h"
@@ -597,14 +598,22 @@ void ConnectionContext::checkClosed(boos
     checkClosed(ssn);
     if ((pn_link_state(lnk) & REQUIRES_CLOSE) == REQUIRES_CLOSE) {
         pn_condition_t* error = pn_link_remote_condition(lnk);
+        std::string name;
         std::stringstream text;
         if (pn_condition_is_set(error)) {
-            text << "Link detached by peer with " << pn_condition_get_name(error) << ": " << pn_condition_get_description(error);
+            name = pn_condition_get_name(error);
+            text << "Link detached by peer with " << name << ": " << pn_condition_get_description(error);
         } else {
             text << "Link detached by peer";
         }
         pn_link_close(lnk);
-        throw qpid::messaging::LinkError(text.str());
+        if (name == qpid::amqp::error_conditions::NOT_FOUND) {
+            throw qpid::messaging::NotFound(text.str());
+        } else if (name == qpid::amqp::error_conditions::UNAUTHORIZED_ACCESS) {
+            throw qpid::messaging::UnauthorizedAccess(text.str());
+        } else {
+            throw qpid::messaging::LinkError(text.str());
+        }
     } else if ((pn_link_state(lnk) & IS_CLOSED) == IS_CLOSED) {
         throw qpid::messaging::LinkError("Link is not attached");
     }

Modified: qpid/trunk/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py?rev=1571688&r1=1571687&r2=1571688&view=diff
==============================================================================
--- qpid/trunk/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py (original)
+++ qpid/trunk/qpid/tests/src/py/qpid_tests/broker_0_10/new_api.py Tue Feb 25 13:47:27 2014
@@ -48,6 +48,13 @@ class GeneralTests(Base):
     def setup_session(self):
         return self.conn.session()
 
+    def test_not_found(self):
+        ssn = self.setup_session()
+        try:
+            ssn.receiver("does-not-exist")
+            self.fail("Expected non-existent node to cause NotFound exception")
+        except NotFound, e: None
+
     def test_qpid_3481_acquired_to_alt_exchange(self):
         """
         Verify that acquired messages are routed to the alternate when the queue is deleted.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org