private IActionResult HandleError(IExceptionHandlerPathFeature feature) { var ex = feature.Error; AppResult result; if (ex is AppValidationException validEx) { result = validEx.Result; StatusCodeStyle = Resources.BadRequestMessageStyle; MessageTitle = Localizer[Resources.BadRequestMessageTitle]; Code = (int)HttpStatusCode.BadRequest; } else if (ex is AuthorizationException authEx) { if (authEx.IsUnauthorized) { result = AppResult.Unauthorized(_resultLocalizer); StatusCodeStyle = Resources.UnauthorizedMessageStyle; MessageTitle = Localizer[Resources.UnauthorizedMessageTitle]; Code = (int)HttpStatusCode.Unauthorized; } else { result = AppResult.AccessDenied(_resultLocalizer); StatusCodeStyle = Resources.AccessDeniedMessageStyle; MessageTitle = Localizer[Resources.AccessDeniedMessageTitle]; Code = (int)HttpStatusCode.Forbidden; } } else if (ex is AppException appEx) { result = appEx.Result; StatusCodeStyle = Resources.ErrorMessageStyle; MessageTitle = Localizer[Resources.ErrorMessageTitle]; Code = (int)HttpStatusCode.InternalServerError; } else { if (_env.IsDevelopment()) { result = AppResult.Error(_resultLocalizer, data: ex, mess: ex.Message); } else { result = AppResult.Error(_resultLocalizer, Localizer[Resources.ErrorMessage]); } StatusCodeStyle = Resources.ErrorMessageStyle; MessageTitle = Localizer[Resources.ErrorMessageTitle]; Code = (int)HttpStatusCode.InternalServerError; } Message = result.Message; RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; OriginalUrl = feature.Path; return(Page()); }