File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
projects/RabbitMQ.Client/client Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -121,14 +121,32 @@ public Exception Exception
121
121
/// Override ToString to be useful for debugging.
122
122
/// </summary>
123
123
public override string ToString ( )
124
+ {
125
+ return GetMessageCore ( )
126
+ + ( _exception != null ? $ ", exception={ _exception } " : string . Empty ) ;
127
+ }
128
+
129
+ /// <summary>
130
+ /// Gets a message suitable for logging.
131
+ /// </summary>
132
+ /// <remarks>
133
+ /// This leaves out the full exception ToString since logging will include it separately.
134
+ /// </remarks>
135
+ internal string GetLogMessage ( )
136
+ {
137
+ return GetMessageCore ( )
138
+ + ( _exception != null ? $ ", exception={ _exception . Message } " : string . Empty ) ;
139
+ }
140
+
141
+ private string GetMessageCore ( )
124
142
{
125
143
return $ "AMQP close-reason, initiated by { Initiator } "
126
144
+ $ ", code={ ReplyCode } "
127
145
+ ( ReplyText != null ? $ ", text='{ ReplyText } '" : string . Empty )
128
146
+ $ ", classId={ ClassId } "
129
147
+ $ ", methodId={ MethodId } "
130
- + ( Cause != null ? $ ", cause={ Cause } " : string . Empty )
131
- + ( _exception != null ? $ ", exception={ _exception } " : string . Empty ) ;
148
+ + ( Cause != null ? $ ", cause={ Cause } " : string . Empty ) ;
132
149
}
150
+
133
151
}
134
152
}
Original file line number Diff line number Diff line change @@ -175,16 +175,17 @@ private void TerminateMainloop()
175
175
176
176
private void HandleMainLoopException ( ShutdownEventArgs reason )
177
177
{
178
+ string message = reason . GetLogMessage ( ) ;
178
179
if ( ! SetCloseReason ( reason ) )
179
180
{
180
- LogCloseError ( $ "Unexpected Main Loop Exception while closing: { reason } ", reason . Exception ) ;
181
+ LogCloseError ( $ "Unexpected Main Loop Exception while closing: { message } ", reason . Exception ) ;
181
182
return ;
182
183
}
183
184
184
185
_channel0 . MaybeSetConnectionStartException ( reason . Exception ) ;
185
186
186
187
OnShutdown ( reason ) ;
187
- LogCloseError ( $ "Unexpected connection closure: { reason } ", reason . Exception ) ;
188
+ LogCloseError ( $ "Unexpected connection closure: { message } ", reason . Exception ) ;
188
189
}
189
190
190
191
private async Task HardProtocolExceptionHandlerAsync ( HardProtocolException hpe , CancellationToken cancellationToken )
You can’t perform that action at this time.
0 commit comments