From 845ca08af3434fc81436c2523fad7b3f8f754d0b Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Wed, 19 Apr 2023 01:56:40 +0200 Subject: [PATCH] Added missing properties to `OpenApiException` --- src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs b/src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs index 8584948..0976a74 100644 --- a/src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs +++ b/src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs @@ -6,10 +6,12 @@ open System.Threading.Tasks open System.Text.Json open System.Text.Json.Serialization -type OpenApiException(code: int, description: string) = +type OpenApiException(code: int, description: string, headers: Headers.HttpResponseHeaders, content: HttpContent) = inherit Exception(description) member _.StatusCode = code member _.Description = description + member _.Headers = headers + member _.Content = content type ProvidedApiClientBase(httpClient: HttpClient, options: JsonSerializerOptions) = @@ -48,7 +50,7 @@ type ProvidedApiClientBase(httpClient: HttpClient, options: JsonSerializerOption |> Array.tryFindIndex((=) codeStr) |> Option.iter(fun idx -> let desc = errorDescriptions[idx] - raise(OpenApiException(code, desc))) + raise(OpenApiException(code, desc, response.Headers, response.Content))) // fail with HttpRequestException if we do not know error description return response.EnsureSuccessStatusCode().Content