From c6608cee0aa944a4f013dc48bb7b321b63640a79 Mon Sep 17 00:00:00 2001 From: Okke Date: Tue, 7 Mar 2017 10:10:11 +0100 Subject: [PATCH] Added even more debug code for the channelimpl class --- include/connectionimpl.h | 20 ++++++++++++++++++++ src/channelimpl.cpp | 10 ++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/connectionimpl.h b/include/connectionimpl.h index 89bc538..c221c01 100644 --- a/include/connectionimpl.h +++ b/include/connectionimpl.h @@ -213,6 +213,26 @@ public: return _state == state_connected; } + /** + * Are we closing down? + * @return bool + */ + bool closing() const + { + // state must be connected + return _state == state_closing; + } + + /** + * Are we closed? + * @return bool + */ + bool closed() const + { + // state must be connected + return _state == state_closed; + } + /** * Mark the connection as connected */ diff --git a/src/channelimpl.cpp b/src/channelimpl.cpp index 2b771e6..305e238 100644 --- a/src/channelimpl.cpp +++ b/src/channelimpl.cpp @@ -84,9 +84,15 @@ void ChannelImpl::onError(const ErrorCallback &callback) // if the connection is valid, this is a pure channel error if (_connection->connected()) return callback("Channel is in an error state, but the connection is valid"); - + + // the connection is closing down + if (_connection->closing()) return callback("Channel is in an error state, the AMQP connection is closing down"); + + // the connection is already closed + if (_connection->closed()) return callback("Channel is in an error state, the AMQP connection has been closed"); + // direct call if channel is already in error state - callback("Channel is in error state because no AMQP connection is available"); + callback("Channel is in error state, something went wrong with the AMQP connection"); } /**