Skip to content

Commit af21f0f

Browse files
committed
Don't crash the whole Hound.SessionServer on a single exception
1 parent 1844fed commit af21f0f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/hound/session_server.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ defmodule Hound.SessionServer do
3535

3636

3737
def change_current_session_for_pid(pid, session_name, opts) do
38-
GenServer.call(@name, {:change_session, pid, session_name, opts}, 60000)
38+
{:ok, session_id} =
39+
GenServer.call(@name, {:change_session, pid, session_name, opts}, 60000)
40+
session_id
3941
end
4042

4143

@@ -80,7 +82,9 @@ defmodule Hound.SessionServer do
8082
end
8183

8284
:ets.insert(@name, {pid, ref, session_id, sessions})
83-
{:reply, session_id, Map.put(state, ref, pid)}
85+
{:reply, {:ok, session_id}, Map.put(state, ref, pid)}
86+
rescue
87+
error -> {:reply, {:error, error}, state}
8488
end
8589

8690
def handle_call({:destroy_sessions, pid}, _from, state) do

0 commit comments

Comments
 (0)