diff options
| author | Gordon Sim <gsim@apache.org> | 2014-02-25 13:47:27 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2014-02-25 13:47:27 +0000 |
| commit | 13d6180840fdd8d11b3bdcad3965e0d942b02756 (patch) | |
| tree | 258a23ddd3ec61d888ffdda68ebeabfd1f5ed7fc /qpid/cpp/src | |
| parent | ddba94d2538db03bdca182ab29309ebf83cd81c9 (diff) | |
| download | qpid-python-13d6180840fdd8d11b3bdcad3965e0d942b02756.tar.gz | |
QPID-5584: use more specific exception types where appropriate
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1571688 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp index 0083a2e390..6d182f40f8 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp @@ -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(boost::shared_ptr<SessionContext> ssn, pn_li 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"); } |
