Skip to content

Commit 4b2cf48

Browse files
committed
Fix FunctionClauseError when attempting to handle message in error state
1 parent 9af4ebe commit 4b2cf48

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/ex_turn/client.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ defmodule ExTURN.Client do
233233
case {permission, channel} do
234234
{false, nil} ->
235235
Logger.warning("""
236-
Tyring to send data but there is no permission for: #{inspect(ip)}. Ignoring.
236+
Trying to send data but there is no permission for: #{inspect(ip)}. Ignoring.
237237
""")
238238

239239
{:ok, client}
@@ -262,7 +262,12 @@ defmodule ExTURN.Client do
262262
end
263263

264264
@spec handle_message(t(), message()) :: on_handle_message()
265-
def handle_message(%__MODULE__{state: state} = client, msg) when state != :error do
265+
def handle_message(%__MODULE__{state: :error} = client, _msg) do
266+
Logger.debug("Trying to handle internal/external message in state: error. Ignoring.")
267+
{:error, :invalid_state, client}
268+
end
269+
270+
def handle_message(client, msg) do
266271
do_handle_message(client, msg)
267272
end
268273

0 commit comments

Comments
 (0)