File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed
projects/RabbitMQ.Client/client Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -123,17 +123,34 @@ public Exception Exception
123123 /// </summary>
124124 public string ReplyText { get ; private set ; }
125125
126- /// <summary>
127- /// Override ToString to be useful for debugging.
128- /// </summary>
129- public override string ToString ( )
126+ private string GetMessageCore ( )
130127 {
131128 return $ "AMQP close-reason, initiated by { Initiator } "
132129 + $ ", code={ ReplyCode } "
133130 + ( ReplyText != null ? $ ", text='{ ReplyText } '" : string . Empty )
134131 + $ ", classId={ ClassId } "
135132 + $ ", methodId={ MethodId } "
136- + ( Cause != null ? $ ", cause={ Cause } " : string . Empty )
133+ + ( Cause != null ? $ ", cause={ Cause } " : string . Empty ) ;
134+ }
135+
136+ /// <summary>
137+ /// Gets a message suitable for logging.
138+ /// </summary>
139+ /// <remarks>
140+ /// This leaves out the full exception ToString since logging will include it separately.
141+ /// </remarks>
142+ internal string GetLogMessage ( )
143+ {
144+ return GetMessageCore ( )
145+ + ( _exception != null ? $ ", exception={ _exception . Message } " : string . Empty ) ;
146+ }
147+
148+ /// <summary>
149+ /// Override ToString to be useful for debugging.
150+ /// </summary>
151+ public override string ToString ( )
152+ {
153+ return GetMessageCore ( )
137154 + ( _exception != null ? $ ", exception={ _exception } " : string . Empty ) ;
138155 }
139156 }
Original file line number Diff line number Diff line change @@ -455,16 +455,17 @@ public void HandleDomainUnload(object sender, EventArgs ea)
455455
456456 public void HandleMainLoopException ( ShutdownEventArgs reason )
457457 {
458+ string message = reason . GetLogMessage ( ) ;
458459 if ( ! SetCloseReason ( reason ) )
459460 {
460- LogCloseError ( $ "Unexpected Main Loop Exception while closing: { reason } ", reason . Exception ) ;
461+ LogCloseError ( $ "Unexpected Main Loop Exception while closing: { message } ", reason . Exception ) ;
461462 return ;
462463 }
463464
464465 _model0 . MaybeSetConnectionStartException ( reason . Exception ) ;
465466
466467 OnShutdown ( ) ;
467- LogCloseError ( $ "Unexpected connection closure: { reason } ", reason . Exception ) ;
468+ LogCloseError ( $ "Unexpected connection closure: { message } ", reason . Exception ) ;
468469 }
469470
470471 public bool HardProtocolExceptionHandler ( HardProtocolException hpe )
You can’t perform that action at this time.
0 commit comments