@@ -142,20 +142,10 @@ private static PerformedContext InvokeServerFilter(
142
142
{
143
143
var filter = enumerator . Current ! ;
144
144
145
- try
146
- {
147
- preContext . Profiler . InvokeMeasured (
148
- new KeyValuePair < IServerFilter , PerformingContext > ( filter , preContext ) ,
149
- InvokeOnPerforming ,
150
- static ctx => $ "OnPerforming for { ctx . Value . BackgroundJob . Id } " ) ;
151
- }
152
- catch ( Exception filterException ) when ( filterException . IsCatchableExceptionType ( ) )
153
- {
154
- CoreBackgroundJobPerformer . HandleJobPerformanceException (
155
- filterException ,
156
- preContext . CancellationToken , preContext . BackgroundJob ) ;
157
- throw ;
158
- }
145
+ preContext . Profiler . InvokeMeasured (
146
+ new KeyValuePair < IServerFilter , PerformingContext > ( filter , preContext ) ,
147
+ InvokeOnPerforming ,
148
+ static ctx => $ "OnPerforming for { ctx . Value . BackgroundJob . Id } " ) ;
159
149
160
150
if ( preContext . Canceled )
161
151
{
@@ -179,21 +169,10 @@ private static PerformedContext InvokeServerFilter(
179
169
postContext = new PerformedContext (
180
170
preContext , null , false , ex ) ;
181
171
182
- try
183
- {
184
- postContext . Profiler . InvokeMeasured (
185
- new KeyValuePair < IServerFilter , PerformedContext > ( filter , postContext ) ,
186
- InvokeOnPerformed ,
187
- static ctx => $ "OnPerformed for { ctx . Value . BackgroundJob . Id } ") ;
188
- }
189
- catch ( Exception filterException ) when ( filterException . IsCatchableExceptionType ( ) )
190
- {
191
- CoreBackgroundJobPerformer . HandleJobPerformanceException (
192
- filterException ,
193
- postContext . CancellationToken , postContext . BackgroundJob ) ;
194
-
195
- throw ;
196
- }
172
+ postContext . Profiler . InvokeMeasured (
173
+ new KeyValuePair < IServerFilter , PerformedContext > ( filter , postContext ) ,
174
+ InvokeOnPerformed ,
175
+ static ctx => $ "OnPerformed for { ctx . Value . BackgroundJob . Id } ") ;
197
176
198
177
if ( ! postContext . ExceptionHandled )
199
178
{
@@ -203,34 +182,41 @@ private static PerformedContext InvokeServerFilter(
203
182
204
183
if ( ! wasError )
205
184
{
206
- try
207
- {
208
- postContext . Profiler . InvokeMeasured (
209
- new KeyValuePair < IServerFilter , PerformedContext > ( filter , postContext ) ,
210
- InvokeOnPerformed ,
211
- static ctx => $ "OnPerformed for { ctx . Value . BackgroundJob . Id } ") ;
212
- }
213
- catch ( Exception filterException ) when ( filterException . IsCatchableExceptionType ( ) )
214
- {
215
- CoreBackgroundJobPerformer . HandleJobPerformanceException (
216
- filterException ,
217
- postContext . CancellationToken , postContext . BackgroundJob ) ;
218
-
219
- throw ;
220
- }
185
+ postContext . Profiler . InvokeMeasured (
186
+ new KeyValuePair < IServerFilter , PerformedContext > ( filter , postContext ) ,
187
+ InvokeOnPerformed ,
188
+ static ctx => $ "OnPerformed for { ctx . Value . BackgroundJob . Id } ") ;
221
189
}
222
190
223
191
return postContext ;
224
192
}
225
193
226
- private static void InvokeOnPerforming ( KeyValuePair < IServerFilter , PerformingContext > x )
194
+ private static void InvokeOnPerforming ( KeyValuePair < IServerFilter , PerformingContext > ctx )
227
195
{
228
- x . Key . OnPerforming ( x . Value ) ;
196
+ try
197
+ {
198
+ ctx . Key . OnPerforming ( ctx . Value ) ;
199
+ }
200
+ catch ( Exception filterException ) when ( filterException . IsCatchableExceptionType ( ) )
201
+ {
202
+ CoreBackgroundJobPerformer . HandleJobPerformanceException (
203
+ filterException ,
204
+ ctx . Value . CancellationToken , ctx . Value . BackgroundJob ) ;
205
+ }
229
206
}
230
207
231
- private static void InvokeOnPerformed ( KeyValuePair < IServerFilter , PerformedContext > x )
208
+ private static void InvokeOnPerformed ( KeyValuePair < IServerFilter , PerformedContext > ctx )
232
209
{
233
- x . Key . OnPerformed ( x . Value ) ;
210
+ try
211
+ {
212
+ ctx . Key . OnPerformed ( ctx . Value ) ;
213
+ }
214
+ catch ( Exception filterException ) when ( filterException . IsCatchableExceptionType ( ) )
215
+ {
216
+ CoreBackgroundJobPerformer . HandleJobPerformanceException (
217
+ filterException ,
218
+ ctx . Value . CancellationToken , ctx . Value . BackgroundJob ) ;
219
+ }
234
220
}
235
221
236
222
private static void InvokeServerExceptionFilters (
@@ -246,9 +232,18 @@ private static void InvokeServerExceptionFilters(
246
232
}
247
233
}
248
234
249
- private static void InvokeOnServerException ( KeyValuePair < IServerExceptionFilter , ServerExceptionContext > x )
235
+ private static void InvokeOnServerException ( KeyValuePair < IServerExceptionFilter , ServerExceptionContext > ctx )
250
236
{
251
- x . Key . OnServerException ( x . Value ) ;
237
+ try
238
+ {
239
+ ctx . Key . OnServerException ( ctx . Value ) ;
240
+ }
241
+ catch ( Exception filterException ) when ( filterException . IsCatchableExceptionType ( ) )
242
+ {
243
+ CoreBackgroundJobPerformer . HandleJobPerformanceException (
244
+ filterException ,
245
+ ctx . Value . CancellationToken , ctx . Value . BackgroundJob ) ;
246
+ }
252
247
}
253
248
}
254
249
}
0 commit comments