diff options
| author | Charles E. Rolke <chug@apache.org> | 2010-11-02 20:50:54 +0000 |
|---|---|---|
| committer | Charles E. Rolke <chug@apache.org> | 2010-11-02 20:50:54 +0000 |
| commit | 958647601758a9cbd78082a76c3583c3ce9e852e (patch) | |
| tree | 6cdf429527ceca889f12ffbfa79b5f52efe69b9c /cpp/bindings/qpid/dotnet/src/Receiver.cpp | |
| parent | a3185a06c97c8775b58e6b5207674f0c1c51e287 (diff) | |
| download | qpid-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/Receiver.cpp')
| -rw-r--r-- | cpp/bindings/qpid/dotnet/src/Receiver.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/cpp/bindings/qpid/dotnet/src/Receiver.cpp index 87ad299078..ea612861e5 100644 --- a/cpp/bindings/qpid/dotnet/src/Receiver.cpp +++ b/cpp/bindings/qpid/dotnet/src/Receiver.cpp @@ -46,9 +46,24 @@ namespace Messaging { // unmanaged clone
Receiver::Receiver(const ::qpid::messaging::Receiver & r,
Org::Apache::Qpid::Messaging::Session ^ sessRef) :
- receiverp(new ::qpid::messaging::Receiver (r)),
parentSession(sessRef)
{
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ receiverp = new ::qpid::messaging::Receiver (r);
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+
+ if (newException != nullptr)
+ {
+ throw newException;
+ }
}
// unmanaged clone
@@ -69,11 +84,26 @@ namespace Messaging { // Copy constructor
- Receiver::Receiver(const Receiver ^ receiver)
- : receiverp(new ::qpid::messaging::Receiver(
- *(const_cast<Receiver ^>(receiver)->NativeReceiver))),
- parentSession(receiver->parentSession)
+ Receiver::Receiver(const Receiver ^ receiver) :
+ parentSession(receiver->parentSession)
{
+ System::Exception ^ newException = nullptr;
+
+ try
+ {
+ receiverp = new ::qpid::messaging::Receiver(
+ *(const_cast<Receiver ^>(receiver)->NativeReceiver));
+ }
+ catch (const ::qpid::types::Exception & error)
+ {
+ String ^ errmsg = gcnew String(error.what());
+ newException = gcnew QpidException(errmsg);
+ }
+
+ if (newException != nullptr)
+ {
+ throw newException;
+ }
}
|
