@@ -23,10 +23,7 @@ public async Task BeforeDisconnectExceptionDoesNotPreventDisconnectAsync()
23
23
Assert . True ( client . IsConnected ( ) ) ;
24
24
25
25
// Add event handler that throws an exception
26
- client . BeforeDisconnect += ( sender , args ) =>
27
- {
28
- throw new Exception ( "Test exception in BeforeDisconnect" ) ;
29
- } ;
26
+ client . BeforeDisconnect += ( sender , args ) => throw new InvalidOperationException ( "Test exception in BeforeDisconnect" ) ;
30
27
31
28
// Attempt to disconnect - should succeed despite the exception
32
29
var disconnectResult = await client . DisconnectAsync ( ) . ConfigureAwait ( false ) ;
@@ -50,10 +47,7 @@ public async Task OnPublishSentExceptionDoesNotPreventPublishAsync()
50
47
Assert . True ( connectResult . ReasonCode == ConnAckReasonCode . Success ) ;
51
48
52
49
// Add event handler that throws an exception
53
- client . OnPublishSent += ( sender , args ) =>
54
- {
55
- throw new Exception ( "Test exception in OnPublishSent" ) ;
56
- } ;
50
+ client . OnPublishSent += ( sender , args ) => throw new InvalidOperationException ( "Test exception in OnPublishSent" ) ;
57
51
58
52
// Attempt to publish - should succeed despite the exception
59
53
var publishResult = await client . PublishAsync (
@@ -85,10 +79,7 @@ public async Task BeforeSubscribeExceptionDoesNotPreventSubscribeAsync()
85
79
Assert . True ( connectResult . ReasonCode == ConnAckReasonCode . Success ) ;
86
80
87
81
// Add event handler that throws an exception
88
- client . BeforeSubscribe += ( sender , args ) =>
89
- {
90
- throw new Exception ( "Test exception in BeforeSubscribe" ) ;
91
- } ;
82
+ client . BeforeSubscribe += ( sender , args ) => throw new InvalidOperationException ( "Test exception in BeforeSubscribe" ) ;
92
83
93
84
// Attempt to subscribe - should succeed despite the exception
94
85
var subscribeResult = await client . SubscribeAsync (
@@ -126,10 +117,7 @@ public async Task BeforeUnsubscribeExceptionDoesNotPreventUnsubscribeAsync()
126
117
Assert . NotEmpty ( subscribeResult . Subscriptions ) ;
127
118
128
119
// Add event handler that throws an exception
129
- client . BeforeUnsubscribe += ( sender , args ) =>
130
- {
131
- throw new Exception ( "Test exception in BeforeUnsubscribe" ) ;
132
- } ;
120
+ client . BeforeUnsubscribe += ( sender , args ) => throw new InvalidOperationException ( "Test exception in BeforeUnsubscribe" ) ;
133
121
134
122
// Attempt to unsubscribe - should succeed despite the exception
135
123
var unsubscribeResult = await client . UnsubscribeAsync (
@@ -167,16 +155,10 @@ public async Task OnMessageReceivedExceptionDoesNotPreventMessageDeliveryAsync()
167
155
Assert . NotEmpty ( subscribeResult . Subscriptions ) ;
168
156
169
157
// Add event handler that throws an exception
170
- client . OnMessageReceived += ( sender , args ) =>
171
- {
172
- throw new Exception ( "Test exception in OnMessageReceived" ) ;
173
- } ;
158
+ client . OnMessageReceived += ( sender , args ) => throw new InvalidOperationException ( "Test exception in OnMessageReceived" ) ;
174
159
175
160
// Add another event handler to verify message was still delivered
176
- client . OnMessageReceived += ( sender , args ) =>
177
- {
178
- messageReceived = true ;
179
- } ;
161
+ client . OnMessageReceived += ( sender , args ) => messageReceived = true ;
180
162
181
163
// Publish a message
182
164
var publishResult = await client . PublishAsync (
@@ -207,10 +189,7 @@ public async Task BeforeConnectExceptionDoesNotPreventConnectAsync()
207
189
var client = new HiveMQClient ( options ) ;
208
190
209
191
// Add event handler that throws an exception
210
- client . BeforeConnect += ( sender , args ) =>
211
- {
212
- throw new Exception ( "Test exception in BeforeConnect" ) ;
213
- } ;
192
+ client . BeforeConnect += ( sender , args ) => throw new InvalidOperationException ( "Test exception in BeforeConnect" ) ;
214
193
215
194
// Attempt to connect - should succeed despite the exception
216
195
var connectResult = await client . ConnectAsync ( ) . ConfigureAwait ( false ) ;
@@ -238,16 +217,10 @@ public async Task OnPubAckReceivedExceptionDoesNotPreventQoS1DeliveryAsync()
238
217
Assert . True ( connectResult . ReasonCode == ConnAckReasonCode . Success ) ;
239
218
240
219
// Add event handler that throws an exception
241
- client . OnPubAckReceived += ( sender , args ) =>
242
- {
243
- throw new Exception ( "Test exception in OnPubAckReceived" ) ;
244
- } ;
220
+ client . OnPubAckReceived += ( sender , args ) => throw new InvalidOperationException ( "Test exception in OnPubAckReceived" ) ;
245
221
246
222
// Add another event handler to verify PubAck was still received
247
- client . OnPubAckReceived += ( sender , args ) =>
248
- {
249
- pubAckReceived = true ;
250
- } ;
223
+ client . OnPubAckReceived += ( sender , args ) => pubAckReceived = true ;
251
224
252
225
// Publish a QoS 1 message
253
226
var publishResult = await client . PublishAsync (
0 commit comments