X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fhttp%2Fhttp.ex;h=c5f720bc9f756292f0c99d2c44500911ca19062f;hb=5ece901af3e887664653c79c5e61618cc5cf0ecf;hp=75c58e6c9a07dce77d77389cd489ab338b15ba92;hpb=04b1c135543965860029557fc216eb38fd63b6c7;p=akkoma diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex index 75c58e6c9..c5f720bc9 100644 --- a/lib/pleroma/http/http.ex +++ b/lib/pleroma/http/http.ex @@ -27,21 +27,29 @@ defmodule Pleroma.HTTP do """ def request(method, url, body \\ "", headers \\ [], options \\ []) do - options = - process_request_options(options) - |> process_sni_options(url) - - params = Keyword.get(options, :params, []) - - %{} - |> Builder.method(method) - |> Builder.headers(headers) - |> Builder.opts(options) - |> Builder.url(url) - |> Builder.add_param(:body, :body, body) - |> Builder.add_param(:query, :query, params) - |> Enum.into([]) - |> (&Tesla.request(Connection.new(), &1)).() + try do + options = + process_request_options(options) + |> process_sni_options(url) + + params = Keyword.get(options, :params, []) + + %{} + |> Builder.method(method) + |> Builder.headers(headers) + |> Builder.opts(options) + |> Builder.url(url) + |> Builder.add_param(:body, :body, body) + |> Builder.add_param(:query, :query, params) + |> Enum.into([]) + |> (&Tesla.request(Connection.new(options), &1)).() + rescue + e -> + {:error, e} + catch + :exit, e -> + {:error, e} + end end defp process_sni_options(options, nil), do: options