Exception: Vagrant::Errors::VagrantError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/vagrant/errors.rb

Overview

Main superclass of any errors in Vagrant. This provides some convenience methods for setting the status code and error key. The status code is used by the vagrant executable as the error code, and the error key is used as a default message from I18n.

Direct Known Subclasses

ActiveMachineWithDifferentProvider, AnsibleFailed, AnsiblePlaybookAppNotFound, BatchMultiError, BoxAddDirectVersion, BoxAddMetadataMultiURL, BoxAddNameMismatch, BoxAddNameRequired, BoxAddNoMatchingProvider, BoxAddNoMatchingVersion, BoxAddShortNotFound, BoxAlreadyExists, BoxChecksumInvalidType, BoxChecksumMismatch, BoxConfigChangingBox, BoxMetadataCorrupted, BoxMetadataDownloadError, BoxMetadataFileNotFound, BoxMetadataMalformed, BoxMetadataMalformedVersion, BoxNotFound, BoxNotFoundWithProvider, BoxNotFoundWithProviderAndVersion, BoxProviderDoesntMatch, BoxRemoveMultiProvider, BoxRemoveMultiVersion, BoxRemoveNotFound, BoxRemoveProviderNotFound, BoxRemoveVersionNotFound, BoxServerNotSet, BoxUnpackageFailure, BoxUpdateMultiProvider, BoxUpdateNoMetadata, BoxVerificationFailed, BundlerDisabled, BundlerError, CFEngineBootstrapFailed, CFEngineCantAutodetectIP, CFEngineInstallFailed, CFEngineNotInstalled, CLIInvalidOptions, CLIInvalidUsage, CapabilityHostExplicitNotDetected, CapabilityHostNotDetected, CapabilityInvalid, CapabilityNotFound, CommandUnavailable, CommunicatorNotFound, ConfigInvalid, ConfigUpgradeErrors, CopyPrivateKeyFailed, CorruptMachineIndex, DarwinNFSMountFailed, DestroyRequiresForce, DotfileUpgradeJSONError, DownloaderError, EnvironmentLockedError, EnvironmentNonExistentCWD, ForwardPortAdapterNotFound, ForwardPortAutolistEmpty, ForwardPortCollision, GuestCapabilityInvalid, GuestCapabilityNotFound, GuestExplicitNotDetected, GuestNotDetected, HomeDirectoryLaterVersion, HomeDirectoryNotAccessible, HomeDirectoryUnknownVersion, HostExplicitNotDetected, LinuxMountFailed, LinuxNFSMountFailed, LinuxRDesktopNotFound, LocalDataDirectoryNotAccessible, MachineActionLockedError, MachineGuestNotReady, MachineLocked, MachineNotFound, MachineStateInvalid, MultiVMTargetRequired, NFSBadExports, NFSCantReadExports, NFSClientNotInstalledInGuest, NFSNoGuestIP, NFSNoHostIP, NFSNoHostonlyNetwork, NFSNoValidIds, NFSNotSupported, NetworkCollision, NetworkDHCPAlreadyAttached, NetworkNotFound, NoDefaultSyncedFolderImpl, NoEnvironmentError, PackageIncludeMissing, PackageIncludeSymlink, PackageOutputDirectory, PackageOutputExists, PackageRequiresDirectory, PluginGemNotFound, PluginInstallLicenseNotFound, PluginInstallVersionConflict, PluginLoadError, PluginNotInstalled, PluginStateFileParseError, PluginUninstallSystem, ProviderNotFound, ProviderNotUsable, ProvisionerFlagInvalid, ProvisionerWinRMUnsupported, RSyncError, RSyncNotFound, RSyncNotInstalledInGuest, SCPPermissionDenied, SCPUnavailable, SSHAuthenticationFailed, SSHConnectEACCES, SSHConnectionRefused, SSHConnectionReset, SSHConnectionTimeout, SSHDisconnected, SSHHostDown, SSHInvalidShell, SSHIsPuttyLink, SSHKeyBadOwner, SSHKeyBadPermissions, SSHKeyTypeNotSupported, SSHNoRoute, SSHNotReady, SSHRunRequiresKeys, SSHUnavailable, SSHUnavailableWindows, SharedFolderCreateFailed, ShellExpandFailed, SyncedFolderUnusable, UIExpectsTTY, UnimplementedProviderAction, VBoxManageError, VBoxManageNotFoundError, VMBaseMacNotSpecified, VMBootBadState, VMBootTimeout, VMCustomizationFailed, VMImportFailure, VMInaccessible, VMNameExists, VMNoMatchError, VMNotCreatedError, VMNotFoundError, VMNotRunningError, VMPowerOffToPackage, VagrantInterrupt, VagrantVersionBad, VagrantfileExistsError, VagrantfileLoadError, VagrantfileSyntaxError, VagrantfileWriteError, VirtualBoxBrokenVersion040214, VirtualBoxGuestPropertyNotFound, VirtualBoxInstallIncomplete, VirtualBoxInvalidVersion, VirtualBoxKernelModuleNotLoaded, VirtualBoxNoRoomForHighLevelNetwork, VirtualBoxNotDetected, Plugin::V1::Guest::BaseError

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (VagrantError) initialize(*args)



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/vagrant/errors.rb', line 62

def initialize(*args)
  key     = args.shift if args.first.is_a?(Symbol)
  message = args.shift if args.first.is_a?(Hash)
  message ||= {}
  @extra_data    = message.dup
  message[:_key] ||= error_key
  message[:_namespace] ||= error_namespace
  message[:_key] = key if key

  if message[:_key]
    message = translate_error(message)
  else
    message = error_message
  end

  super(message)
end

Instance Attribute Details

- (Object) extra_data

This is extra data passed into the message for translation.



47
48
49
# File 'lib/vagrant/errors.rb', line 47

def extra_data
  @extra_data
end

Class Method Details

+ (Object) error_key(key = nil, namespace = nil)



49
50
51
52
# File 'lib/vagrant/errors.rb', line 49

def self.error_key(key=nil, namespace=nil)
  define_method(:error_key) { key }
  error_namespace(namespace) if namespace
end

+ (Object) error_message(message)



54
55
56
# File 'lib/vagrant/errors.rb', line 54

def self.error_message(message)
  define_method(:error_message) { message }
end

+ (Object) error_namespace(namespace)



58
59
60
# File 'lib/vagrant/errors.rb', line 58

def self.error_namespace(namespace)
  define_method(:error_namespace) { namespace }
end

Instance Method Details

- (Object) error_key

The key for the error message. This should be set using the error_key method but can be overridden here if needed.



91
# File 'lib/vagrant/errors.rb', line 91

def error_key; nil; end

- (Object) error_message

The error message for this error. This is used if no error_key is specified for a translatable error message.



82
# File 'lib/vagrant/errors.rb', line 82

def error_message; "No error message"; end

- (Object) error_namespace

The default error namespace which is used for the error key. This can be overridden here or by calling the "error_namespace" class method.



87
# File 'lib/vagrant/errors.rb', line 87

def error_namespace; "vagrant.errors"; end

- (Integer) status_code

This is the exit code that should be used when exiting from this exception.



97
# File 'lib/vagrant/errors.rb', line 97

def status_code; 1; end