From e15692c2adaecc26da975393dfee6c205126310f 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: Tue, 4 Feb 2025 12:25:18 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=D1=81=D1=8F=20=D0=BE=D1=82=20System.Configuration.Config?= =?UTF-8?q?urationManager=20=D0=B2=20DD.Persistence.Client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettingsPropertyNotFoundException.cs | 20 +++++++++++++++++++ .../DD.Persistence.Client.csproj | 1 - DD.Persistence.Client/RefitClientFactory.cs | 5 ++--- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 DD.Persistence.Client/CustomExceptions/SettingsPropertyNotFoundException.cs 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..28535f5 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; @@ -26,7 +25,7 @@ public class RefitClientFactory : IRefitClientFactory where T : IRefitClie var baseUrl = configuration.GetSection("ClientUrl").Get(); if (String.IsNullOrEmpty(baseUrl)) { - var exception = new SettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса."); + var exception = new AppSettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса."); logger.LogError(exception.Message);