@@ -73,40 +73,50 @@ public class PublishReturnException : PublishException
73
73
{
74
74
private readonly string _exchange ;
75
75
private readonly string _routingKey ;
76
+ private readonly ushort _replyCode ;
77
+ private readonly string _replyText ;
76
78
77
- public PublishReturnException ( ulong publishSequenceNumber , string exchange , string routingKey )
79
+ public PublishReturnException ( ulong publishSequenceNumber ,
80
+ string ? exchange = null , string ? routingKey = null ,
81
+ ushort ? replyCode = null , string ? replyText = null )
78
82
: base ( publishSequenceNumber , true )
79
83
{
80
- _exchange = exchange ;
81
- _routingKey = routingKey ;
84
+ _exchange = exchange ?? string . Empty ;
85
+ _routingKey = routingKey ?? string . Empty ;
86
+ _replyCode = replyCode ?? 0 ;
87
+ _replyText = replyText ?? string . Empty ;
82
88
}
83
89
84
90
/// <summary>
85
- /// Get the Exchange associated with this <c>basic.return</c>
91
+ /// Get the exchange associated with this <c>basic.return</c>
86
92
/// </summary>
87
93
public string Exchange => _exchange ;
88
94
89
95
/// <summary>
90
- /// Get the RoutingKey associated with this <c>basic.return</c>
96
+ /// Get the routing key associated with this <c>basic.return</c>
91
97
/// </summary>
92
98
public string RoutingKey => _routingKey ;
99
+
100
+ /// <summary>
101
+ /// Get the reply code associated with this <c>basic.return</c>
102
+ /// </summary>
103
+ public ushort ReplyCode => _replyCode ;
104
+
105
+ /// <summary>
106
+ /// Get the reply text associated with this <c>basic.return</c>
107
+ /// </summary>
108
+ public string ReplyText => _replyText ;
93
109
}
94
110
95
111
internal static class PublishExceptionFactory
96
112
{
97
113
internal static PublishException Create ( bool isReturn ,
98
- ulong deliveryTag , string ? exchange = null , string ? routingKey = null )
114
+ ulong deliveryTag , string ? exchange = null , string ? routingKey = null ,
115
+ ushort ? replyCode = null , string ? replyText = null )
99
116
{
100
117
if ( isReturn )
101
118
{
102
- if ( exchange is not null && routingKey is not null )
103
- {
104
- return new PublishReturnException ( deliveryTag , exchange , routingKey ) ;
105
- }
106
- else
107
- {
108
- return new PublishException ( deliveryTag , isReturn ) ;
109
- }
119
+ return new PublishReturnException ( deliveryTag , exchange , routingKey , replyCode , replyText ) ;
110
120
}
111
121
else
112
122
{
0 commit comments