Class: Vagrant::Smartos::Zones::Util::GlobalZone::Connection::ErrorHandler

Inherits:
Struct
  • Object
show all
Defined in:
lib/vagrant/smartos/zones/util/global_zone/connection.rb

Constant Summary collapse

ERROR_MAPPING =
{
  # This happens on connect() for unknown reasons yet...
  Errno::EACCES => Vagrant::Errors::SSHConnectEACCES,
  # This happens if we continued to timeout when attempting to connect.
  Errno::ETIMEDOUT => Vagrant::Errors::SSHConnectionTimeout,
  Timeout::Error => Vagrant::Errors::SSHConnectionTimeout,
  # This happens if authentication failed. We wrap the error in our own exception.
  Net::SSH::AuthenticationFailed => Vagrant::Errors::SSHAuthenticationFailed,
  # This happens if the remote server unexpectedly closes the
  # connection. This is usually raised when SSH is running on the
  # other side but can't properly setup a connection. This is
  # usually a server-side issue.
  Net::SSH::Disconnect => Vagrant::Errors::SSHDisconnected,
  # This is raised if we failed to connect the max amount of times
  Errno::ECONNREFUSED => Vagrant::Errors::SSHConnectionRefused,
  # This is raised if we failed to connect the max number of times
  # due to an ECONNRESET.
  Errno::ECONNRESET => Vagrant::Errors::SSHConnectionReset,
  # This is raised if we get an ICMP DestinationUnknown error.
  Errno::EHOSTDOWN => Vagrant::Errors::SSHHostDown,
  # This is raised if we can't work out how to route traffic.
  Errno::EHOSTUNREACH => Vagrant::Errors::SSHNoRoute,
  # This is raised if a private key type that Net-SSH doesn't support
  # is used. Show a nicer error.
  NotImplementedError => Vagrant::Errors::SSHKeyTypeNotSupported
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#errorObject

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



31
32
33
# File 'lib/vagrant/smartos/zones/util/global_zone/connection.rb', line 31

def error
  @error
end

Instance Method Details

#handle!Object



59
60
61
62
# File 'lib/vagrant/smartos/zones/util/global_zone/connection.rb', line 59

def handle!
  error_class = ERROR_MAPPING[error.class]
  raise error_class if error_class
end