Skip to content

Commit

Permalink
(FIXUP) Simplify error messages in ConnectionFailure
Browse files Browse the repository at this point in the history
Some more cleanup for the removal of the gettext-setup dependency
  • Loading branch information
caseywilliams committed Nov 5, 2021
1 parent 19457cc commit 22564c3
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/puppet_forge/connection/connection_failure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22564c3

Please sign in to comment.