From d0cd647849e267f5c010aeb85e2281059f9099c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Thu, 26 Dec 2024 15:47:24 +0500 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=B1=D1=80=D0=BE=D1=81=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F,=20?= =?UTF-8?q?=D0=B5=D1=81=D0=BB=D0=B8=20=D0=B2=20appsettings.json=20=D0=B2?= =?UTF-8?q?=20=D1=81=D0=B5=D0=BA=D1=86=D0=B8=D0=B8=20ClientUrl=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0=D0=BD=20=D0=BF=D1=83?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B4=D0=BE=20Persistence-=D1=81=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DD.Persistence.Client/DD.Persistence.Client.csproj | 1 + DD.Persistence.Client/RefitClientFactory.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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);