Skip to content

Commit

Permalink
Elaborate on the "AMQP Publish Fail" error message
Browse files Browse the repository at this point in the history
  • Loading branch information
reunanen committed May 23, 2023
1 parent 4f37847 commit bb27b38
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/AMQPExchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,20 @@ void AMQPExchange::sendPublishCommand(amqp_bytes_t messageByte, const char * key
free(entries);

if ( 0 > res ) {
throw AMQPException("AMQP Publish Fail." );
const std::string errorMessage = [res]() -> std::string {
switch (res) {
case AMQP_STATUS_TIMER_FAILURE: return "The underlying system timer facility failed";
case AMQP_STATUS_HEARTBEAT_TIMEOUT: return "Timed out waiting for heartbeat";
case AMQP_STATUS_NO_MEMORY: return "Memory allocation failed";
case AMQP_STATUS_TABLE_TOO_BIG: return "The amqp_table_t object cannot be serialized because the output buffer is too small";
case AMQP_STATUS_CONNECTION_CLOSED: return "The connection to the broker has been closed";
case AMQP_STATUS_SSL_ERROR: return "A generic SSL error occurred";
case AMQP_STATUS_TCP_ERROR: return "A generic TCP error occurred";
default: return "Unknown error (" + std::to_string(res) + ")";
}
}();

throw AMQPException("AMQP Publish Fail: " + errorMessage);
}
}

Expand Down

0 comments on commit bb27b38

Please sign in to comment.