Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<Compile Include="..\SwaggerProvider.Runtime\ProvidedApiClientBase.fs">
<Link>ProvidedApiClientBase.fs</Link>
</Compile>
<Compile Include="..\SwaggerProvider.Runtime\Exception.fs" />
<Compile Include="..\SwaggerProvider.Runtime\RuntimeHelpers.fs" />
<Compile Include="..\Common\AssemblyInfo.fs">
<Link>AssemblyInfo.fs</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/SwaggerProvider.DesignTime/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module SchemaReader =

return
if String.IsNullOrEmpty err then
raise wex
wex.Reraise()
else
err.ToString()
| Choice2Of2 e -> return failwith(e.ToString())
Expand Down
4 changes: 1 addition & 3 deletions src/SwaggerProvider.DesignTime/v2/Parser/Parsers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,7 @@ module Parsers =
else
match Int32.TryParse(property) with
| true, value -> Some value
| false, _ ->
raise
<| UnknownFieldValueException(obj, property, "HTTP Status Code", spec)
| false, _ -> raise(UnknownFieldValueException(obj, property, "HTTP Status Code", spec))

code, parseResponseObject context objValue)

Expand Down
7 changes: 5 additions & 2 deletions src/SwaggerProvider.DesignTime/v2/Parser/SwaggerParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ open SwaggerProvider.Internal.v2.Parser.Schema
open SwaggerProvider.Internal.v2.Parser.Exceptions

module internal JsonAdapter =

open System.Text.Json

/// Schema node for Swagger schemes in Json format
Expand Down Expand Up @@ -52,9 +53,11 @@ module internal JsonAdapter =
(JsonDocument.Parse string).RootElement |> JsonNodeAdapter

module internal YamlAdapter =

open System
open System.Collections.Generic
open System.IO
open YamlDotNet.Serialization
open System.Collections.Generic

let (|List|_|)(node: obj) =
match node with
Expand Down Expand Up @@ -138,7 +141,7 @@ module internal YamlAdapter =
use reader = new StringReader(text)
deserializer.Deserialize(reader) |> YamlNodeAdapter
with
| :? YamlDotNet.Core.YamlException as e when not <| isNull e.InnerException -> raise e.InnerException // inner exceptions are much more informative
| :? YamlDotNet.Core.YamlException as e when not <| isNull e.InnerException -> e.InnerException.Reraise() // inner exceptions are much more informative
| _ -> reraise()

module SwaggerParser =
Expand Down
16 changes: 16 additions & 0 deletions src/SwaggerProvider.Runtime/Exception.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[<AutoOpen>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module System.Exception

open System
open System.Diagnostics
open System.Runtime.ExceptionServices

// Useful for reraising exceptions under an async {...} and task {...} contexts
// See this for more details: https://github.com/fsharp/fslang-suggestions/issues/660
type Exception with

[<DebuggerHidden>]
member __.Reraise() =
(ExceptionDispatchInfo.Capture __).Throw()
Unchecked.defaultof<_>
1 change: 1 addition & 0 deletions src/SwaggerProvider.Runtime/SwaggerProvider.Runtime.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<Compile Include="..\Common\AssemblyInfo.fs">
<Link>AssemblyInfo.fs</Link>
</Compile>
<Compile Include="Exception.fs" />
<Compile Include="Runtime.fs" />
<Compile Include="ProvidedApiClientBase.fs" />
<Compile Include="RuntimeHelpers.fs" />
Expand Down