diff --git a/DD.Persistence.Client/DD.Persistence.Client.csproj b/DD.Persistence.Client/DD.Persistence.Client.csproj index d1ae186..8acc827 100644 --- a/DD.Persistence.Client/DD.Persistence.Client.csproj +++ b/DD.Persistence.Client/DD.Persistence.Client.csproj @@ -53,6 +53,7 @@ + diff --git a/DD.Persistence.Client/RefitClientFactory.cs b/DD.Persistence.Client/RefitClientFactory.cs index a83aae5..2b010e2 100644 --- a/DD.Persistence.Client/RefitClientFactory.cs +++ b/DD.Persistence.Client/RefitClientFactory.cs @@ -1,7 +1,9 @@ using DD.Persistence.Client.Clients.Interfaces.Refit; using DD.Persistence.Client.Helpers; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using Refit; +using System.Configuration; using System.Text.Json; namespace DD.Persistence.Client; @@ -18,11 +20,19 @@ public class RefitClientFactory : IRefitClientFactory where T : IRefitClie /// /// /// - public RefitClientFactory(IConfiguration configuration) + public RefitClientFactory(IConfiguration configuration, ILogger> logger) { this.client = new HttpClient(); - var baseUrl = configuration.GetSection("ClientUrl").Get()!; + var baseUrl = configuration.GetSection("ClientUrl").Get(); + if (String.IsNullOrEmpty(baseUrl)) + { + var exception = new SettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса."); + + logger.LogError(exception.Message); + + throw exception; + } client.BaseAddress = new Uri(baseUrl); client.Authorize(configuration);