throw error

This commit is contained in:
Warunee Tamkoo 2025-10-17 23:30:49 +07:00
parent a94947289d
commit 9f326f24fb

View file

@ -1129,7 +1129,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
Degree = workSheet?.Cells[row, 18]?.GetValue<string>() ?? "",
Major = workSheet?.Cells[row, 19]?.GetValue<string>() == "อื่น ๆ" ? workSheet?.Cells[row, 20]?.GetValue<string>() ?? "" : workSheet?.Cells[row, 19]?.GetValue<string>() ?? "",
MajorGroupId = "",
MajorGroupName = "",
MajorGroupName = "",
University = workSheet?.Cells[row, 21]?.GetValue<string>() == "อื่น ๆ" ? workSheet?.Cells[row, 22]?.GetValue<string>() ?? "" : workSheet?.Cells[row, 21]?.GetValue<string>() ?? "",
GPA = (double)workSheet?.Cells[row, 26]?.GetValue<double>(),
Specialist = "",
@ -2644,12 +2644,44 @@ namespace BMA.EHR.Recruit.Service.Controllers
{
try
{
_logger.LogInformation($"Starting UpdateAsyncRecruitToPlacement for examId: {examId}, AccountStartDate: {req?.AccountStartDate}");
if (req == null)
{
_logger.LogError("RecruitDateRequest is null");
return Error("ข้อมูลคำขอไม่ถูกต้อง", StatusCodes.Status400BadRequest);
}
if (examId == Guid.Empty)
{
_logger.LogError("ExamId is empty");
return Error("รหัสการสอบไม่ถูกต้อง", StatusCodes.Status400BadRequest);
}
await _recruitService.UpdateAsyncRecruitToPlacement(examId, req.AccountStartDate);
_logger.LogInformation($"Successfully completed UpdateAsyncRecruitToPlacement for examId: {examId}");
return Success();
}
catch (ArgumentException argEx)
{
_logger.LogError(argEx, $"Argument error in UpdateAsyncRecruitToPlacement for examId: {examId}");
return Error($"ข้อมูลไม่ถูกต้อง: {argEx.Message}", StatusCodes.Status400BadRequest);
}
catch (InvalidOperationException opEx)
{
_logger.LogError(opEx, $"Invalid operation in UpdateAsyncRecruitToPlacement for examId: {examId}");
return Error($"การดำเนินการไม่ถูกต้อง: {opEx.Message}", StatusCodes.Status422UnprocessableEntity);
}
catch (TimeoutException timeEx)
{
_logger.LogError(timeEx, $"Timeout in UpdateAsyncRecruitToPlacement for examId: {examId}");
return Error("การดำเนินการใช้เวลานานเกินไป กรุณาลองใหม่อีกครั้ง", StatusCodes.Status408RequestTimeout);
}
catch (Exception ex)
{
return Error(ex);
_logger.LogError(ex, $"Unexpected error in UpdateAsyncRecruitToPlacement for examId: {examId}, Message: {ex.Message}, StackTrace: {ex.StackTrace}");
return Error($"เกิดข้อผิดพลาดในการโอนคนแข่งขันไปบรรจุ: {ex.Message}", StatusCodes.Status500InternalServerError);
}
}