@@ -53,16 +53,34 @@ await ReceiveLoop()
53
53
catch ( EndOfStreamException eose )
54
54
{
55
55
// Possible heartbeat exception
56
- HandleMainLoopException ( new ShutdownEventArgs ( ShutdownInitiator . Library , 0 , "End of stream" , eose ) ) ;
56
+ var ea = new ShutdownEventArgs ( ShutdownInitiator . Library ,
57
+ 0 , "End of stream" ,
58
+ exception : eose ) ;
59
+ HandleMainLoopException ( ea ) ;
57
60
}
58
61
catch ( HardProtocolException hpe )
59
62
{
60
63
await HardProtocolExceptionHandler ( hpe )
61
64
. ConfigureAwait ( false ) ;
62
65
}
66
+ catch ( FileLoadException fileLoadException )
67
+ {
68
+ /*
69
+ * https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/1434
70
+ * Ensure that these exceptions eventually make it to application code
71
+ */
72
+ var ea = new ShutdownEventArgs ( ShutdownInitiator . Library ,
73
+ Constants . InternalError , fileLoadException . Message ,
74
+ exception : fileLoadException ) ;
75
+ HandleMainLoopException ( ea ) ;
76
+ }
63
77
catch ( Exception ex )
64
78
{
65
- HandleMainLoopException ( new ShutdownEventArgs ( ShutdownInitiator . Library , Constants . InternalError , "Unexpected Exception" , ex ) ) ;
79
+ var ea = new ShutdownEventArgs ( ShutdownInitiator . Library ,
80
+ Constants . InternalError ,
81
+ $ "Unexpected Exception: { ex . Message } ",
82
+ exception : ex ) ;
83
+ HandleMainLoopException ( ea ) ;
66
84
}
67
85
68
86
FinishClose ( ) ;
@@ -146,15 +164,17 @@ private void HandleMainLoopException(ShutdownEventArgs reason)
146
164
{
147
165
if ( ! SetCloseReason ( reason ) )
148
166
{
149
- // TODO reason.Cause could be an Exception, should we use that?
150
- LogCloseError ( "Unexpected Main Loop Exception while closing: " + reason , new Exception ( reason . ToString ( ) ) ) ;
167
+ LogCloseError ( $ "Unexpected Main Loop Exception while closing: { reason } ", reason . Exception ) ;
151
168
return ;
152
169
}
153
170
171
+ _channel0 . MaybeSetConnectionStartException ( reason . Exception ) ;
172
+
154
173
OnShutdown ( reason ) ;
155
- LogCloseError ( $ "Unexpected connection closure: { reason } ", new Exception ( reason . ToString ( ) ) ) ;
174
+ LogCloseError ( $ "Unexpected connection closure: { reason } ", reason . Exception ) ;
156
175
}
157
176
177
+ // TODO rename Async, add cancellation token?
158
178
private async Task HardProtocolExceptionHandler ( HardProtocolException hpe )
159
179
{
160
180
if ( SetCloseReason ( hpe . ShutdownReason ) )
0 commit comments