Skip to content

Commit

Permalink
InvalidMessageException -> InvalidWebsocketMessageException
Browse files Browse the repository at this point in the history
  • Loading branch information
valbers committed Mar 17, 2024
1 parent 38fed3c commit 0cfd55c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/FSharp.Data.GraphQL.Server.AspNetCore/Exceptions.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FSharp.Data.GraphQL.Server.AspNetCore

type InvalidMessageException (explanation : string) =
type InvalidWebsocketMessageException (explanation : string) =
inherit System.Exception (explanation)
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type GraphQLWebSocketMiddleware<'Root>
try
return JsonSerializer.Deserialize<ClientMessage> (msg, serializerOptions)
with
| :? InvalidMessageException as e -> return! Result.Error <| InvalidMessage (4400, e.Message.ToString ())
| :? InvalidWebsocketMessageException as e -> return! Result.Error <| InvalidMessage (4400, e.Message.ToString ())
| :? JsonException as e ->
if logger.IsEnabled (LogLevel.Debug) then
logger.LogDebug (e.ToString ())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open FSharp.Data.GraphQL.Server.AspNetCore.WebSockets
type ClientMessageConverter () =
inherit JsonConverter<ClientMessage> ()

let raiseInvalidMsg explanation = raise <| InvalidMessageException explanation
let raiseInvalidMsg explanation = raise <| InvalidWebsocketMessageException explanation

/// From the spec: "Receiving a message of a type or format which is not specified in this document will result in an immediate socket closure with the event 4400: &lt;error-message&gt;.
/// The &lt;error-message&gt; can be vaguely descriptive on why the received message is invalid."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let willResultInInvalidMessage expectedExplanation input =
Assert.Fail (sprintf "should have failed, but succeeded with result: '%A'" result)
with
| :? JsonException as ex -> Assert.Equal (expectedExplanation, ex.Message)
| :? InvalidMessageException as ex -> Assert.Equal (expectedExplanation, ex.Message)
| :? InvalidWebsocketMessageException as ex -> Assert.Equal (expectedExplanation, ex.Message)

let willResultInJsonException input =
try
Expand Down

0 comments on commit 0cfd55c

Please sign in to comment.