@@ -42,7 +42,7 @@ public class PublishException : RabbitMQClientException
42
42
private bool _isReturn = false ;
43
43
private ulong _publishSequenceNumber = ulong . MinValue ;
44
44
45
- public PublishException ( ulong publishSequenceNumber , bool isReturn ) : base ( )
45
+ public PublishException ( ulong publishSequenceNumber , bool isReturn , string message ) : base ( message )
46
46
{
47
47
if ( publishSequenceNumber == ulong . MinValue )
48
48
{
@@ -76,10 +76,10 @@ public class PublishReturnException : PublishException
76
76
private readonly ushort _replyCode ;
77
77
private readonly string _replyText ;
78
78
79
- public PublishReturnException ( ulong publishSequenceNumber ,
79
+ public PublishReturnException ( ulong publishSequenceNumber , string message ,
80
80
string ? exchange = null , string ? routingKey = null ,
81
81
ushort ? replyCode = null , string ? replyText = null )
82
- : base ( publishSequenceNumber , true )
82
+ : base ( publishSequenceNumber , true , message )
83
83
{
84
84
_exchange = exchange ?? string . Empty ;
85
85
_routingKey = routingKey ?? string . Empty ;
@@ -116,11 +116,13 @@ internal static PublishException Create(bool isReturn,
116
116
{
117
117
if ( isReturn )
118
118
{
119
- return new PublishReturnException ( deliveryTag , exchange , routingKey , replyCode , replyText ) ;
119
+ string message = $ "{ replyCode } { replyText } Exchange: { exchange } Routing Key: { routingKey } ";
120
+ return new PublishReturnException ( deliveryTag , message , exchange , routingKey , replyCode , replyText ) ;
120
121
}
121
122
else
122
123
{
123
- return new PublishException ( deliveryTag , isReturn ) ;
124
+ string message = "Message rejected by broker." ;
125
+ return new PublishException ( deliveryTag , isReturn , message ) ;
124
126
}
125
127
}
126
128
}
0 commit comments