Skip to content

Commit

Permalink
Added missing properties to OpenApiException
Browse files Browse the repository at this point in the history
  • Loading branch information
xperiandri committed Apr 18, 2023
1 parent 3327c01 commit 845ca08
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/SwaggerProvider.Runtime/ProvidedApiClientBase.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 845ca08

Please sign in to comment.