diff --git a/DD.Persistence.App/appsettings.json b/DD.Persistence.App/appsettings.json index 7ad8c67..12b91e4 100644 --- a/DD.Persistence.App/appsettings.json +++ b/DD.Persistence.App/appsettings.json @@ -21,5 +21,5 @@ "grantType": "password", "http://schemas.xmlsoap.org/ws/2005/05/identity /claims/nameidentifier": "7d9f3574-6574-4ca3-845a-0276eb4aa8f6" }, - "ClientUrl": "http://localhost:5000/" + "PeristenceClientUrl": "http://localhost:5000/" } diff --git a/DD.Persistence.Client/CustomExceptions/SettingsPropertyNotFoundException.cs b/DD.Persistence.Client/CustomExceptions/SettingsPropertyNotFoundException.cs new file mode 100644 index 0000000..6baa108 --- /dev/null +++ b/DD.Persistence.Client/CustomExceptions/SettingsPropertyNotFoundException.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DD.Persistence.Client.CustomExceptions; + +/// +/// Ошибка, которая выбрасывается в случае отсутствия необходимого свойства в appsettings.json +/// +public class AppSettingsPropertyNotFoundException : Exception +{ + /// + /// + /// + /// + public AppSettingsPropertyNotFoundException(string message) + : base(message) { } +} diff --git a/DD.Persistence.Client/DD.Persistence.Client.csproj b/DD.Persistence.Client/DD.Persistence.Client.csproj index 2395482..1d91345 100644 --- a/DD.Persistence.Client/DD.Persistence.Client.csproj +++ b/DD.Persistence.Client/DD.Persistence.Client.csproj @@ -52,7 +52,6 @@ - diff --git a/DD.Persistence.Client/RefitClientFactory.cs b/DD.Persistence.Client/RefitClientFactory.cs index 9cd0bef..7072944 100644 --- a/DD.Persistence.Client/RefitClientFactory.cs +++ b/DD.Persistence.Client/RefitClientFactory.cs @@ -1,9 +1,8 @@ using DD.Persistence.Client.Clients.Interfaces.Refit; -using DD.Persistence.Client.Helpers; +using DD.Persistence.Client.CustomExceptions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Refit; -using System.Configuration; using System.Text.Json; namespace DD.Persistence.Client; @@ -23,10 +22,10 @@ public class RefitClientFactory : IRefitClientFactory where T : IRefitClie //this.client = factory.CreateClient(); this.client = client; - var baseUrl = configuration.GetSection("ClientUrl").Get(); + var baseUrl = configuration.GetSection("PeristenceClientUrl").Get(); if (String.IsNullOrEmpty(baseUrl)) { - var exception = new SettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса."); + var exception = new AppSettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса."); logger.LogError(exception.Message);