Class: PuppetForge::Connection::ConnectionFailure Private

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/shared/puppet_forge/connection/connection_failure.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Wrap Faraday connection failures to include the host and optional proxy in use for the failed connection.

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/shared/puppet_forge/connection/connection_failure.rb', line 8

def call(env)
  @app.call(env)
rescue Faraday::ConnectionFailed => e
  baseurl = env[:url].dup
  baseurl.path = ''
  errmsg = "Unable to connect to #{baseurl.to_s}"
  if proxy = env[:request][:proxy]
    errmsg << " (using proxy #{proxy.uri.to_s})"
  end
  errmsg << ": #{e.message}"
  m = Faraday::ConnectionFailed.new(errmsg)
  m.set_backtrace(e.backtrace)
  raise m
end