Skip to content

Commit

Permalink
Resolve opaque struct match dialyzer warning
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Sep 26, 2024
1 parent bd38264 commit ef9de79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
1 change: 0 additions & 1 deletion .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
~r"MACRO",
~r"lib/phoenix/router.ex",
~r"lib/slipstream/connection/impl.ex",
]
31 changes: 17 additions & 14 deletions lib/slipstream/connection/impl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,25 @@ defmodule Slipstream.Connection.Impl do
# ---

def push_message(frame, state) when is_tuple(frame) do
with {:ok, websocket, data} <-
Mint.WebSocket.encode(state.websocket, frame),
{:ok, conn} <-
Mint.WebSocket.stream_request_body(
state.conn,
state.request_ref,
data
) do
{:ok, %State{state | conn: conn, websocket: websocket}}
else
case Mint.WebSocket.encode(state.websocket, frame) do
{:ok, websocket, data} ->
case Mint.WebSocket.stream_request_body(
state.conn,
state.request_ref,
data
) do
{:ok, conn} ->
{:ok, %State{state | conn: conn, websocket: websocket}}

# coveralls-ignore-start
{:error, conn, reason} ->
{:error, put_in(state.conn, conn), reason}
# coveralls-ignore-stop
end

# coveralls-ignore-start
{:error, %Mint.WebSocket{} = websocket, reason} ->
{:error, websocket, reason} ->
{:error, put_in(state.websocket, websocket), reason}

{:error, conn, reason} ->
{:error, put_in(state.conn, conn), reason}
# coveralls-ignore-stop
end
end
Expand Down

0 comments on commit ef9de79

Please sign in to comment.