修改异常处理
parent
ed8791c9d7
commit
22df12f221
|
@ -35,8 +35,7 @@ namespace IRaCIS.Core.Application.Filter
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.Result = new JsonResult(ResponseOutput.NotOk(" 程序异常,请联系开发人员。 " + (context.Exception.InnerException is null ? (context.Exception.Message /*+ context.Exception.StackTrace*/)
|
context.Result = new JsonResult(ResponseOutput.NotOk("当前操作失败,请联系开发人员查看系统日志排查 ", ApiResponseCodeEnum.ProgramException));
|
||||||
: (context.Exception.InnerException?.Message /*+ context.Exception.InnerException?.StackTrace*/)), ApiResponseCodeEnum.ProgramException));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MailKit;
|
using MailKit;
|
||||||
using MailKit.Security;
|
using MailKit.Security;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
|
@ -42,7 +43,7 @@ public static class SendEmailHelper
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
throw new Exception("邮件发送失败,您进行的操作未能成功,请检查邮箱或联系维护人员");
|
throw new BusinessValidationFailedException("邮件发送失败,您进行的操作未能成功,请检查邮箱或联系维护人员");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ public static class SendEmailHelper
|
||||||
|
|
||||||
if (sMTPEmailConfig.ToMailAddressList.Count == 0)
|
if (sMTPEmailConfig.ToMailAddressList.Count == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("没有收件人");
|
throw new BusinessValidationFailedException("没有收件人");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,7 @@ using Panda.DynamicWebApi.Attributes;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace IRaCIS.Application.Services
|
namespace IRaCIS.Application.Services
|
||||||
{
|
{
|
||||||
|
@ -22,6 +23,8 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
private readonly IMemoryCache _cache;
|
private readonly IMemoryCache _cache;
|
||||||
|
|
||||||
|
private ILogger<UserService> _logger;
|
||||||
|
|
||||||
private readonly IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig;
|
private readonly IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig;
|
||||||
public UserService(IRepository<User> userRepository,
|
public UserService(IRepository<User> userRepository,
|
||||||
|
|
||||||
|
@ -30,10 +33,12 @@ namespace IRaCIS.Application.Services
|
||||||
IRepository<Doctor> doctorRepository,
|
IRepository<Doctor> doctorRepository,
|
||||||
IMemoryCache cache,
|
IMemoryCache cache,
|
||||||
IRepository<TrialUser> userTrialRepository,
|
IRepository<TrialUser> userTrialRepository,
|
||||||
IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig
|
IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig,
|
||||||
|
ILogger<UserService> logger
|
||||||
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
_logger=logger;
|
||||||
_verifyConfig = verifyConfig;
|
_verifyConfig = verifyConfig;
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
|
@ -267,7 +272,7 @@ namespace IRaCIS.Application.Services
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new BusinessValidationFailedException("请检查邮箱地址或者联系维护人员, 邮件发送失败, 未能创建账户成功");
|
throw new BusinessValidationFailedException("请检查邮箱地址或者联系维护人员, 邮件发送失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -506,8 +511,17 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
var success = await _userRepository.SaveChangesAsync();
|
var success = await _userRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _mailVerificationService.AddUserSendEmailAsync(saveItem.Id, userAddModel.BaseUrl, userAddModel.RouteUrl);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex.Message);
|
||||||
|
throw new BusinessValidationFailedException("发送邮件失败, 未能创建账户成功");
|
||||||
|
}
|
||||||
|
|
||||||
await _mailVerificationService.AddUserSendEmailAsync(saveItem.Id, userAddModel.BaseUrl, userAddModel.RouteUrl);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,17 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
|
||||||
throw new DBSaveFailedException("SQL 查询中存在语法错误。");
|
throw new DBSaveFailedException("SQL 查询中存在语法错误。");
|
||||||
}
|
}
|
||||||
|
catch (ReferenceConstraintException ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex.Message);
|
||||||
|
throw new DBSaveFailedException("无法进行当前操作,当前数据不符合外键约束。");
|
||||||
|
}
|
||||||
|
catch (DbUpdateConcurrencyException ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex.Message);
|
||||||
|
|
||||||
|
throw new DBSaveFailedException("SQL 事务失败,请检查环境。");
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue