qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1163526 - /qpid/trunk/qpid/cpp/bindings/qpid/python/python.i
Date Wed, 31 Aug 2011 08:42:23 GMT
Author: gsim
Date: Wed Aug 31 08:42:23 2011
New Revision: 1163526

URL: http://svn.apache.org/viewvc?rev=1163526&view=rev
Log:
QPID-3333: Patch from Anthony Foglia - Wrap more exceptions (0009)

Modified:
    qpid/trunk/qpid/cpp/bindings/qpid/python/python.i

Modified: qpid/trunk/qpid/cpp/bindings/qpid/python/python.i
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/python/python.i?rev=1163526&r1=1163525&r2=1163526&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qpid/python/python.i (original)
+++ qpid/trunk/qpid/cpp/bindings/qpid/python/python.i Wed Aug 31 08:42:23 2011
@@ -25,8 +25,19 @@
  * convert uint8_t by default. */
 %apply unsigned char { uint8_t };
 
+
+/*
+ * Exceptions
+ *
+ * The convention below is that exceptions in _cqpid.so have the same
+ * names as in the C++ library.  They get renamed to their Python
+ * equivalents when brought into the Python wrapping
+ */
 %{
-static PyObject* pNoMessageAvailable;    
+static PyObject* pNoMessageAvailable;
+static PyObject* pTargetCapacityExceeded;
+static PyObject* pNotFound;
+static PyObject* pTransportFailure;
 %}
 
 %init %{
@@ -34,10 +45,28 @@ static PyObject* pNoMessageAvailable;   
         "_cqpid.NoMessageAvailable", NULL, NULL);
     Py_INCREF(pNoMessageAvailable);
     PyModule_AddObject(m, "NoMessageAvailable", pNoMessageAvailable);
+
+    pTargetCapacityExceeded = PyErr_NewException(
+        "_cqpid.TargetCapacityExceeded", NULL, NULL);
+    Py_INCREF(pTargetCapacityExceeded);
+    PyModule_AddObject(m, "TargetCapacityExceeded", pTargetCapacityExceeded);
+
+    pNotFound = PyErr_NewException(
+        "_cqpid.NotFound", NULL, NULL);
+    Py_INCREF(pNotFound);
+    PyModule_AddObject(m, "NotFound", pNotFound);
+
+    pTransportFailure = PyErr_NewException(
+        "_cqpid.TransportFailure", NULL, NULL);
+    Py_INCREF(pTransportFailure);
+    PyModule_AddObject(m, "TransportFailure", pTransportFailure);
 %}
 
 %pythoncode %{
     Empty = _cqpid.NoMessageAvailable
+    TargetCapacityExceeded = _cqpid.TargetCapacityExceeded
+    NotFound = _cqpid.NotFound
+    ConnectError = _cqpid.TransportFailure
 %}
 
 /* Define the general-purpose exception handling */
@@ -50,6 +79,15 @@ static PyObject* pNoMessageAvailable;   
     } catch (qpid::messaging::NoMessageAvailable & ex) {
         pExceptionType = pNoMessageAvailable;
         error = ex.what();
+    } catch (qpid::messaging::TargetCapacityExceeded & ex) {
+        pExceptionType = pTargetCapacityExceeded;
+        error = ex.what();
+    } catch (qpid::messaging::NotFound & ex) {
+        pExceptionType = pNotFound;
+        error = ex.what();
+    } catch (qpid::messaging::TransportFailure & ex) {
+        pExceptionType = pTransportFailure;
+        error = ex.what();
     } catch (qpid::types::Exception& ex) {
         pExceptionType = PyExc_RuntimeError;
         error = ex.what();
@@ -61,6 +99,7 @@ static PyObject* pNoMessageAvailable;   
     }
 }
 
+
 /* This only renames the non-const version (I believe).  Then again, I
  * don't even know why there is a non-const version of the method. */
 %rename(opened) qpid::messaging::Connection::isOpen();



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message