From 1a728858ebeac294661903d7b5e5540390ad2c8b Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Mon, 25 Nov 2024 14:26:38 +0100 Subject: [PATCH] Update Finch 0.20 support --- lib/req/finch.ex | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/req/finch.ex b/lib/req/finch.ex index e2eb37c..07846a7 100644 --- a/lib/req/finch.ex +++ b/lib/req/finch.ex @@ -113,20 +113,12 @@ defmodule Req.Finch do {:ok, acc} -> acc - {:error, %Mint.TransportError{reason: reason}} -> - {req, %Req.TransportError{reason: reason}} - - {:error, %Mint.HTTPError{module: Mint.HTTP1, reason: reason}} -> - {req, %Req.HTTPError{protocol: :http1, reason: reason}} - - {:error, %Mint.HTTPError{module: Mint.HTTP2, reason: reason}} -> - {req, %Req.HTTPError{protocol: :http2, reason: reason}} - - {:error, %Finch.Error{reason: reason}} -> - {req, %Req.HTTPError{protocol: :http2, reason: reason}} - + # TODO: remove when we require Finch 0.20 {:error, exception} -> - {req, exception} + {req, normalize_error(exception)} + + {:error, exception, _acc} -> + {req, normalize_error(exception)} end end @@ -169,6 +161,9 @@ defmodule Req.Finch do {:error, exception} -> {req, normalize_error(exception)} + {:error, exception, {nil, _req, _resp}} -> + {req, normalize_error(exception)} + {:error, exception, {{acc, collector}, _req, _resp}} -> collector.(acc, :halt) {req, normalize_error(exception)}