Parcourir la source

增强异常处理逻辑,新增错误日志记录

修改了 `catch` 块的异常处理逻辑,增加了对捕获异常的日志记录。通过在 `catch (Exception)` 中新增参数 `e`,捕获异常信息,并使用 `_logger.LogError` 记录日志,日志内容包括固定的错误提示信息和异常的 `Message`。同时,保留了原有的异常处理逻辑,确保在捕获异常后更新相关状态并重新抛出异常。此改动提升了代码的可维护性和问题排查效率。
田爽 il y a 1 semaine
Parent
commit
ccf81ffd7d
1 fichiers modifiés avec 2 ajouts et 1 suppressions
  1. 2 1
      src/Hotline.Application/Quality/QualityApplication.cs

+ 2 - 1
src/Hotline.Application/Quality/QualityApplication.cs

@@ -459,8 +459,9 @@ namespace Hotline.Application.Quality
 					await _qualityRepository.Updateable().SetColumns(x => new Hotline.Quality.Quality { TransferState = EQualityTransferState.Succeed,Transfer = transfers }).Where(x => x.Id == quality.Id).ExecuteCommandAsync();
 					await _qualityTransferRecordsRepository.Updateable().SetColumns(x => new QualityTransferRecords { TransferState = EQualityTransferState.Succeed,IsFinished = true }).Where(x => x.QualityId == quality.Id).ExecuteCommandAsync();
 				}
-				catch (Exception)
+				catch (Exception e)
 				{
+					_logger.LogError($" 兴唐 语音转写报错!,报错原因: \r\n{e.Message}");
 					await _qualityRepository.Updateable().SetColumns(x => new Hotline.Quality.Quality { TransferState = EQualityTransferState.Lose}).Where(x => x.Id == quality.Id).ExecuteCommandAsync();
 					await _qualityTransferRecordsRepository.Updateable().SetColumns(x => new QualityTransferRecords { TransferState = EQualityTransferState.Lose, IsFinished = true }).Where(x => x.QualityId == quality.Id).ExecuteCommandAsync();
 					throw;