Skip to content

Commit 0fc48f1

Browse files
committed
better error handling (#60)
1 parent 2fa25ec commit 0fc48f1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/mongo/topology.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,12 @@ defmodule Mongo.Topology do
332332
end
333333

334334
defp get_connection(nil, _state), do: nil
335-
defp get_connection(address, %{connection_pools: pools}), do: Map.fetch(pools, address)
335+
defp get_connection(address, %{connection_pools: pools}) do
336+
case Map.fetch(pools, address) do
337+
:error -> {:error, Mongo.Error.exception("The server #{inspect address} is no longer available")}
338+
conn -> conn
339+
end
340+
end
336341

337342
defp get_limits(nil, _topology), do: nil
338343
defp get_limits(address, %{servers: servers}) do

0 commit comments

Comments
 (0)