@@ -282,9 +282,16 @@ void handler(object o, EventArgs e)
282
282
}
283
283
}
284
284
}
285
- catch ( OperationCanceledException ex ) when ( aggregateTrainingStopManager . IsStopTrainingRequested ( ) == false )
285
+ catch ( Exception ex ) when ( aggregateTrainingStopManager . IsStopTrainingRequested ( ) == false )
286
286
{
287
- logger . Trace ( $ "trial cancelled - { JsonSerializer . Serialize ( trialSettings ) } , continue training") ;
287
+ var exceptionMessage = $@ "
288
+ Exception thrown during Trial { trialSettings . TrialId } with configuration { JsonSerializer . Serialize ( trialSettings ) }
289
+
290
+ Exception Details: ex.Message
291
+
292
+ Abandoning Trial { trialSettings . TrialId } and continue training.
293
+ " ;
294
+ logger . Trace ( exceptionMessage ) ;
288
295
trialSettings . EndedAtUtc = DateTime . UtcNow ;
289
296
monitor ? . ReportFailTrial ( trialSettings , ex ) ;
290
297
var trialResult = new TrialResult
@@ -296,22 +303,8 @@ void handler(object o, EventArgs e)
296
303
tuner . Update ( trialResult ) ;
297
304
trialResultManager ? . AddOrUpdateTrialResult ( trialResult ) ;
298
305
aggregateTrainingStopManager . Update ( trialResult ) ;
299
- continue ;
300
- }
301
- catch ( OperationCanceledException ) when ( aggregateTrainingStopManager . IsStopTrainingRequested ( ) )
302
- {
303
- logger . Trace ( $ "trial cancelled - { JsonSerializer . Serialize ( trialSettings ) } , stop training") ;
304
-
305
- break ;
306
- }
307
- catch ( Exception ex )
308
- {
309
- logger . Trace ( $ "trial failed - { JsonSerializer . Serialize ( trialSettings ) } , stop training") ;
310
306
311
- trialSettings . EndedAtUtc = DateTime . UtcNow ;
312
- monitor ? . ReportFailTrial ( trialSettings , ex ) ;
313
-
314
- if ( ! aggregateTrainingStopManager . IsStopTrainingRequested ( ) && _bestTrialResult == null )
307
+ if ( ex is not OperationCanceledException && _bestTrialResult == null )
315
308
{
316
309
logger . Trace ( $ "trial fatal error - { JsonSerializer . Serialize ( trialSettings ) } , stop training") ;
317
310
@@ -321,6 +314,13 @@ void handler(object o, EventArgs e)
321
314
// when error is fatal (like schema mismatch).
322
315
throw ;
323
316
}
317
+ continue ;
318
+ }
319
+ catch ( Exception ) when ( aggregateTrainingStopManager . IsStopTrainingRequested ( ) )
320
+ {
321
+ logger . Trace ( $ "trial cancelled - { JsonSerializer . Serialize ( trialSettings ) } , stop training") ;
322
+
323
+ break ;
324
324
}
325
325
finally
326
326
{
0 commit comments