From f9e26972fe2f7742f07c787a67364a114f38c026 Mon Sep 17 00:00:00 2001 From: SergeyMenshykh Date: Wed, 3 Jul 2024 11:40:04 +0100 Subject: [PATCH] fix: remove exception utitlity duplicate. --- dotnet/SK-dotnet.sln | 6 +++ .../ClientResultExceptionExtensions.cs | 39 ------------------- 2 files changed, 6 insertions(+), 39 deletions(-) delete mode 100644 dotnet/src/Connectors/Connectors.AzureOpenAI/ClientResultExceptionExtensions.cs diff --git a/dotnet/SK-dotnet.sln b/dotnet/SK-dotnet.sln index 6da6c33ec47a..7b2e556f616d 100644 --- a/dotnet/SK-dotnet.sln +++ b/dotnet/SK-dotnet.sln @@ -337,6 +337,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Policies", "Policies", "{73 src\InternalUtilities\openai\Policies\GeneratedActionPipelinePolicy.cs = src\InternalUtilities\openai\Policies\GeneratedActionPipelinePolicy.cs EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{738DCDB1-EFA8-4913-AD4C-6FC3F09B0A0C}" + ProjectSection(SolutionItems) = preProject + src\InternalUtilities\openai\Extensions\ClientResultExceptionExtensions.cs = src\InternalUtilities\openai\Extensions\ClientResultExceptionExtensions.cs + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -944,6 +949,7 @@ Global {DB219924-208B-4CDD-8796-EE424689901E} = {1B4CBDE0-10C2-4E7D-9CD0-FE7586C96ED1} {2E79AD99-632F-411F-B3A5-1BAF3F5F89AB} = {4D3DAE63-41C6-4E1C-A35A-E77BDFC40675} {7308EF7D-5F9A-47B2-A62F-0898603262A8} = {2E79AD99-632F-411F-B3A5-1BAF3F5F89AB} + {738DCDB1-EFA8-4913-AD4C-6FC3F09B0A0C} = {2E79AD99-632F-411F-B3A5-1BAF3F5F89AB} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {FBDC56A3-86AD-4323-AA0F-201E59123B83} diff --git a/dotnet/src/Connectors/Connectors.AzureOpenAI/ClientResultExceptionExtensions.cs b/dotnet/src/Connectors/Connectors.AzureOpenAI/ClientResultExceptionExtensions.cs deleted file mode 100644 index fd282797e879..000000000000 --- a/dotnet/src/Connectors/Connectors.AzureOpenAI/ClientResultExceptionExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System.ClientModel; -using System.Net; -using Azure; - -namespace Microsoft.SemanticKernel.Connectors.AzureOpenAI; - -/// -/// Provides extension methods for the class. -/// -internal static class ClientResultExceptionExtensions -{ - /// - /// Converts a to an . - /// - /// The original . - /// An instance. - public static HttpOperationException ToHttpOperationException(this ClientResultException exception) - { - const int NoResponseReceived = 0; - - string? responseContent = null; - - try - { - responseContent = exception.GetRawResponse()?.Content?.ToString(); - } -#pragma warning disable CA1031 // Do not catch general exception types - catch { } // We want to suppress any exceptions that occur while reading the content, ensuring that an HttpOperationException is thrown instead. -#pragma warning restore CA1031 - - return new HttpOperationException( - exception.Status == NoResponseReceived ? null : (HttpStatusCode?)exception.Status, - responseContent, - exception.Message, - exception); - } -}