From 22564c30b044102ffde22dbb86b9ba70e65d5498 Mon Sep 17 00:00:00 2001 From: Casey Williams Date: Fri, 5 Nov 2021 10:24:58 -0700 Subject: [PATCH] (FIXUP) Simplify error messages in ConnectionFailure Some more cleanup for the removal of the gettext-setup dependency --- .../connection/connection_failure.rb | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/puppet_forge/connection/connection_failure.rb b/lib/puppet_forge/connection/connection_failure.rb index 6dd0be8..df2f27f 100644 --- a/lib/puppet_forge/connection/connection_failure.rb +++ b/lib/puppet_forge/connection/connection_failure.rb @@ -9,22 +9,11 @@ def call(env) @app.call(env) rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e baseurl = env[:url].dup - errmsg = "Unable to connect to #{baseurl.to_s}" + errmsg = "Unable to connect to %{scheme}://%{host}" % { scheme: baseurl.scheme, host: baseurl.host } if proxy = env[:request][:proxy] - errmsg << ("Unable to connect to %{scheme}://%{host} (using proxy %{proxy}) (for request %{path_query})") % { - scheme: baseurl.scheme, - host: baseurl.host, - proxy: proxy.uri.to_s, - path_query: baseurl.request_uri, - } - else - errmsg << ("Unable to connect to %{scheme}://%{host} (for request %{path_query})") % { - scheme: baseurl.scheme, - host: baseurl.host, - path_query: baseurl.request_uri, - } + errmsg << " (using proxy %{proxy})" % { proxy: proxy.uri.to_s } end - errmsg << ": #{e.message}" + errmsg << " (for request %{path_query}): %{message}" % { message: e.message, path_query: baseurl.request_uri } m = Faraday::ConnectionFailed.new(errmsg) m.set_backtrace(e.backtrace) raise m