diff --git a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs index 303963d24f..4a806b9ae2 100644 --- a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs +++ b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs @@ -8,6 +8,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AutoMapper; +using Volo.Abp.ExceptionHandling; using Volo.Abp.Identity.AspNetCore; using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation; @@ -19,7 +20,8 @@ namespace Volo.Abp.Account.Web typeof(AbpAccountHttpApiModule), typeof(AbpIdentityAspNetCoreModule), typeof(AbpAutoMapperModule), - typeof(AbpAspNetCoreMvcUiThemeSharedModule) + typeof(AbpAspNetCoreMvcUiThemeSharedModule), + typeof(AbpExceptionHandlingModule) )] public class AbpAccountWebModule : AbpModule { diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs index 3e016c8bb5..c4461bd512 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccountPageModel.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Volo.Abp.Account.Localization; +using Volo.Abp.AspNetCore.ExceptionHandling; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Abp.ExceptionHandling; using Volo.Abp.Identity; using IdentityUser = Volo.Abp.Identity.IdentityUser; @@ -18,6 +19,7 @@ namespace Volo.Abp.Account.Web.Pages.Account public IdentityUserManager UserManager { get; set; } public IdentitySecurityLogManager IdentitySecurityLogManager { get; set; } public IOptions IdentityOptions { get; set; } + public IExceptionToErrorInfoConverter ExceptionToErrorInfoConverter { get; set; } protected AccountPageModel() { @@ -42,5 +44,15 @@ namespace Volo.Abp.Account.Web.Pages.Account throw new ApplicationException($"Current tenant is different than given tenant. CurrentTenant.Id: {CurrentTenant.Id}, given tenantId: {tenantId}"); } } + + protected virtual string GetLocalizeExceptionMessage(Exception exception) + { + if (exception is ILocalizeErrorMessage || exception is IHasErrorCode) + { + return ExceptionToErrorInfoConverter.Convert(exception, false).Message; + } + + return exception.Message; + } } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/ForgotPassword.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/ForgotPassword.cshtml.cs index b66b53c913..1789a6ba2e 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/ForgotPassword.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/ForgotPassword.cshtml.cs @@ -43,7 +43,7 @@ namespace Volo.Abp.Account.Web.Pages.Account } catch (UserFriendlyException e) { - Alerts.Danger(e.Message); + Alerts.Danger(GetLocalizeExceptionMessage(e)); return Page(); } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs index 065573c137..eb6307e6b0 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs @@ -1,8 +1,6 @@ -using System; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Security.Claims; -using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -100,7 +98,7 @@ namespace Volo.Abp.Account.Web.Pages.Account } catch (BusinessException e) { - Alerts.Danger(e.Message); + Alerts.Danger(GetLocalizeExceptionMessage(e)); return Page(); } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/ResetPassword.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/ResetPassword.cshtml.cs index 13370f5fbd..c961fe7e14 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/ResetPassword.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/ResetPassword.cshtml.cs @@ -82,7 +82,7 @@ namespace Volo.Abp.Account.Web.Pages.Account { if (!string.IsNullOrWhiteSpace(e.Message)) { - Alerts.Warning(e.Message); + Alerts.Warning(GetLocalizeExceptionMessage(e)); return Page(); }