From c6ecb6e200cf2e59f678abdda0886d2c42f61548 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 4 Nov 2013 16:02:28 +0000 Subject: QPID-5289: Improvements to error handling and reporting git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1538658 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/broker/amqp/Session.cpp | 6 +++++- qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/qpid/broker/amqp/Session.cpp b/qpid/cpp/src/qpid/broker/amqp/Session.cpp index 25bba04fbd..8ad95e8075 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Session.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Session.cpp @@ -652,7 +652,11 @@ void IncomingToQueue::handle(qpid::broker::Message& message) msg << " Queue " << queue->getName() << " has been deleted"; throw Exception(qpid::amqp::error_conditions::RESOURCE_DELETED, msg.str()); } - queue->deliver(message); + try { + queue->deliver(message); + } catch (const qpid::SessionException& e) { + throw Exception(qpid::amqp::error_conditions::PRECONDITION_FAILED, e.what()); + } } void IncomingToExchange::handle(qpid::broker::Message& message) diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp index 5217bca7e7..f65f8e5eb0 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp @@ -412,8 +412,15 @@ void ConnectionContext::check() } } if ((pn_connection_state(connection) & REQUIRES_CLOSE) == REQUIRES_CLOSE) { + pn_condition_t* error = pn_connection_remote_condition(connection); + std::stringstream text; + if (pn_condition_is_set(error)) { + text << "Connection closed by peer with " << pn_condition_get_name(error) << ": " << pn_condition_get_description(error); + } else { + text << "Connection closed by peer"; + } pn_connection_close(connection); - throw qpid::messaging::ConnectionError("Connection closed by peer"); + throw qpid::messaging::ConnectionError(text.str()); } } -- cgit v1.2.1