Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement of design-time error handling #259

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ NUGET
YamlDotNet (16.3)
GITHUB
remote: fsprojects/FSharp.TypeProviders.SDK
src/ProvidedTypes.fs (b965f9485545d308ced1cde3779c9e66a2a298f2)
src/ProvidedTypes.fsi (b965f9485545d308ced1cde3779c9e66a2a298f2)
src/ProvidedTypes.fs (dc8c662ca2e7d8d11048968ca166df6dc2fd9482)
src/ProvidedTypes.fsi (dc8c662ca2e7d8d11048968ca166df6dc2fd9482)
remote: fsprojects/FSharp.Data
src/FSharp.Data.Runtime.Utilities/NameUtils.fs (09165171f0c4a5e322bd47317f809bd771f5be49)
src/FSharp.Data.Runtime.Utilities/Pluralizer.fs (09165171f0c4a5e322bd47317f809bd771f5be49)
Expand Down
10 changes: 10 additions & 0 deletions src/SwaggerProvider.DesignTime/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@

match res with
| Choice1Of2 x -> return x
| Choice2Of2(:? Swagger.OpenApiException as ex) when not <| isNull ex.Content ->
let content =
ex.Content.ReadAsStringAsync()
|> Async.AwaitTask
|> Async.RunSynchronously

if String.IsNullOrEmpty content then
return ex.Reraise()
else
return content
| Choice2Of2(:? WebException as wex) when not <| isNull wex.Response ->
use stream = wex.Response.GetResponseStream()
use reader = new StreamReader(stream)
Expand All @@ -57,7 +67,7 @@
err.ToString()
| Choice2Of2 e -> return failwith(e.ToString())
| _ ->
let request = WebRequest.Create(schemaPathRaw)

Check warning on line 70 in src/SwaggerProvider.DesignTime/Utils.fs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.

Check warning on line 70 in src/SwaggerProvider.DesignTime/Utils.fs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
use! response = request.GetResponseAsync() |> Async.AwaitTask
use sr = new StreamReader(response.GetResponseStream())
return! sr.ReadToEndAsync() |> Async.AwaitTask
Expand Down
Loading