diff --git a/lib/req/finch.ex b/lib/req/finch.ex index b4ced49..e24a2c9 100644 --- a/lib/req/finch.ex +++ b/lib/req/finch.ex @@ -309,8 +309,12 @@ defmodule Req.Finch do Map.has_key?(request.options, :connect_options) or Map.has_key?(request.options, :inet6) cond do - request.options[:finch] && custom_options? -> - raise ArgumentError, "cannot set both :finch and :connect_options" + name = request.options[:finch] -> + if custom_options? do + raise ArgumentError, "cannot set both :finch and :connect_options" + else + name + end custom_options? -> pool_options = pool_options(request.options) diff --git a/test/req/finch_test.exs b/test/req/finch_test.exs index 15d5822..285b534 100644 --- a/test/req/finch_test.exs +++ b/test/req/finch_test.exs @@ -183,6 +183,12 @@ defmodule Req.FinchTest do end end + test ":finch option" do + assert_raise ArgumentError, "unknown registry: MyFinch", fn -> + Req.get!("http://localhost", finch: MyFinch) + end + end + test ":finch and :connect_options" do assert_raise ArgumentError, "cannot set both :finch and :connect_options", fn -> Req.request!(finch: MyFinch, connect_options: [timeout: 0])