Skip to content

Commit

Permalink
Improve EXITs that happen during calls (#258)
Browse files Browse the repository at this point in the history
Closes #254.
  • Loading branch information
whatyouhide authored Oct 18, 2023
1 parent 7074dd7 commit 0b5c418
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/redix/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ defmodule Redix.Connection do
resp

{:DOWN, ^request_id, _, _, reason} ->
exit(reason)
exit({:redix_exited_during_call, reason})
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/redix/start_options_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ defmodule Redix.StartOptionsTest do
sentinels = opts[:sentinel][:sentinels]

assert Enum.count(sentinels) == 2
assert Enum.find(sentinels, &(&1[:host] == 'host1'))[:password] == "secret1"
assert Enum.find(sentinels, &(&1[:host] == 'host2'))[:password] == "secret2"
assert Enum.find(sentinels, &(&1[:host] == ~c"host1"))[:password] == "secret1"
assert Enum.find(sentinels, &(&1[:host] == ~c"host2"))[:password] == "secret2"
end

test "sentinel password mfa" do
Expand All @@ -141,8 +141,8 @@ defmodule Redix.StartOptionsTest do
sentinels = opts[:sentinel][:sentinels]

assert Enum.count(sentinels) == 2
assert Enum.find(sentinels, &(&1[:host] == 'host1'))[:password] == mfa1
assert Enum.find(sentinels, &(&1[:host] == 'host2'))[:password] == mfa2
assert Enum.find(sentinels, &(&1[:host] == ~c"host1"))[:password] == mfa1
assert Enum.find(sentinels, &(&1[:host] == ~c"host2"))[:password] == mfa2
end

test "gen_statem options are allowed" do
Expand Down
5 changes: 3 additions & 2 deletions test/redix_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ defmodule RedixTest do
Process.exit(conn, :kill)

assert_receive {:EXIT, ^conn, :killed}
assert_receive {:EXIT, ^pid, :killed}
assert_receive {:EXIT, ^pid, {:redix_exited_during_call, :killed}}
end

test "passing a non-list as the command", %{conn: c} do
Expand Down Expand Up @@ -584,7 +584,8 @@ defmodule RedixTest do
# with a hard-to-understand error (see the issue linked above).
_ = Redix.noreply_command(conn, ["INCR", key])

assert {%RuntimeError{} = error, _stacktrace} = catch_exit(Redix.command!(conn, ["PING"]))
assert {:redix_exited_during_call, {%RuntimeError{} = error, _stacktrace}} =
catch_exit(Redix.command!(conn, ["PING"]))

assert Exception.message(error) =~
"failed to find an original command in the commands queue"
Expand Down

0 comments on commit 0b5c418

Please sign in to comment.