summaryrefslogtreecommitdiff
path: root/cpp/bindings/qpid/dotnet/src/Sender.cpp
diff options
context:
space:
mode:
authorCharles E. Rolke <chug@apache.org>2010-11-02 20:50:54 +0000
committerCharles E. Rolke <chug@apache.org>2010-11-02 20:50:54 +0000
commit958647601758a9cbd78082a76c3583c3ce9e852e (patch)
tree6cdf429527ceca889f12ffbfa79b5f52efe69b9c /cpp/bindings/qpid/dotnet/src/Sender.cpp
parenta3185a06c97c8775b58e6b5207674f0c1c51e287 (diff)
downloadqpid-python-958647601758a9cbd78082a76c3583c3ce9e852e.tar.gz
QPID-2923 Qpid Messaging .NET Binding fails to translate exceptions from C++ to .NET
This checkin moves code out of class constructor member initialization and puts it into try-catch blocks. Any SEH Exceptions thrown by the C++ Messaging libraries are caught and re-thrown as .NET exceptions. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1030209 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qpid/dotnet/src/Sender.cpp')
-rw-r--r--cpp/bindings/qpid/dotnet/src/Sender.cpp73
1 files changed, 67 insertions, 6 deletions
diff --git a/cpp/bindings/qpid/dotnet/src/Sender.cpp b/cpp/bindings/qpid/dotnet/src/Sender.cpp
index 0249c511b8..a051026e71 100644
--- a/cpp/bindings/qpid/dotnet/src/Sender.cpp
+++ b/cpp/bindings/qpid/dotnet/src/Sender.cpp
@@ -29,6 +29,7 @@
#include "Sender.h"
#include "Message.h"
+#include "QpidException.h"
namespace Org {
namespace Apache {
@@ -42,9 +43,24 @@ namespace Messaging {
// unmanaged clone
Sender::Sender(const ::qpid::messaging::Sender & s,
Org::Apache::Qpid::Messaging::Session ^ sessRef) :
- senderp(new ::qpid::messaging::Sender (s)),
parentSession(sessRef)
{
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ senderp = new ::qpid::messaging::Sender (s);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+
+ if (newException != nullptr)
+ {
+ throw newException;
+ }
}
@@ -63,10 +79,25 @@ namespace Messaging {
// Copy constructor
Sender::Sender(const Sender ^ sender)
- : senderp(new ::qpid::messaging::Sender(
- *(const_cast<Sender ^>(sender)->NativeSender))),
- parentSession(sender->parentSession)
+ : parentSession(sender->parentSession)
{
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ senderp = new ::qpid::messaging::Sender(
+ *(const_cast<Sender ^>(sender)->NativeSender));
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+
+ if (newException != nullptr)
+ {
+ throw newException;
+ }
}
@@ -91,12 +122,42 @@ namespace Messaging {
void Sender::Send(Message ^ mmsgp, bool sync)
{
- senderp->::qpid::messaging::Sender::send(*((*mmsgp).NativeMessage), sync);
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ senderp->::qpid::messaging::Sender::send(*((*mmsgp).NativeMessage), sync);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+
+ if (newException != nullptr)
+ {
+ throw newException;
+ }
}
void Sender::Close()
{
- senderp->close();
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ senderp->close();
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+
+ if (newException != nullptr)
+ {
+ throw newException;
+ }
}
}}}}