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, AliasInvalidError, BatchMultiError, BoxAddDirectVersion, BoxAddMetadataMultiURL, BoxAddNameMismatch, BoxAddNameRequired, BoxAddNoMatchingProvider, BoxAddNoMatchingVersion, BoxAddShortNotFound, BoxAlreadyExists, BoxChecksumInvalidType, BoxChecksumMismatch, BoxConfigChangingBox, BoxFileNotExist, BoxMetadataCorrupted, BoxMetadataDownloadError, BoxMetadataFileNotFound, BoxMetadataMalformed, BoxMetadataMalformedVersion, BoxMetadataMissingRequiredFields, BoxNotFound, BoxNotFoundWithProvider, BoxNotFoundWithProviderAndVersion, BoxNotFoundWithProviderArchitecture, BoxProviderDoesntMatch, BoxRemoveArchitectureNotFound, BoxRemoveMultiArchitecture, BoxRemoveMultiProvider, BoxRemoveMultiVersion, BoxRemoveNotFound, BoxRemoveProviderNotFound, BoxRemoveVersionNotFound, BoxServerNotSet, BoxUnpackageFailure, BoxUpdateMultiArchitecture, BoxUpdateMultiProvider, BoxUpdateNoMetadata, BoxVerificationFailed, BoxVersionInvalid, BundlerDisabled, BundlerError, CFEngineBootstrapFailed, CFEngineCantAutodetectIP, CFEngineInstallFailed, CFEngineNotInstalled, CLIInvalidOptions, CLIInvalidUsage, CantReadMACAddresses, CapabilityHostExplicitNotDetected, CapabilityHostNotDetected, CapabilityInvalid, CapabilityNotFound, CloneMachineNotFound, CloneNotFound, CloudInitCommandFailed, CloudInitNotFound, CommandDeprecated, CommandSuspendAllArgs, CommandUnavailable, CommunicatorNotFound, ConfigInvalid, ConfigUpgradeErrors, CopyPrivateKeyFailed, CorruptMachineIndex, CreateIsoHostCapNotFound, DarwinMountFailed, DarwinVersionFailed, DestroyRequiresForce, DotfileUpgradeJSONError, DownloadAlreadyInProgress, DownloaderChecksumError, DownloaderError, EnvInval, EnvironmentLockedError, EnvironmentNonExistentCWD, ForwardPortAdapterNotFound, ForwardPortAutolistEmpty, ForwardPortCollision, ForwardPortHostIPNotFound, GuestCapabilityInvalid, GuestCapabilityNotFound, GuestExplicitNotDetected, GuestNotDetected, HomeDirectoryLaterVersion, HomeDirectoryNotAccessible, HomeDirectoryUnknownVersion, HostExplicitNotDetected, HypervVirtualBoxError, ISOBuildFailed, LinuxMountFailed, LinuxRDPClientNotFound, LocalDataDirectoryNotAccessible, MachineActionLockedError, MachineFolderNotAccessible, MachineGuestNotReady, MachineLocked, MachineNotFound, MachineStateInvalid, MultiVMTargetRequired, NFSBadExports, NFSCantReadExports, NFSClientNotInstalledInGuest, NFSDupePerms, NFSExportsFailed, NFSMountFailed, NFSNoGuestIP, NFSNoHostIP, NFSNoHostonlyNetwork, NFSNoValidIds, NFSNotSupported, NetSSHException, NetplanNoAvailableRenderers, NetworkAddressInvalid, NetworkCollision, NetworkDHCPAlreadyAttached, NetworkManagerNotInstalled, NetworkNotFound, NetworkTypeNotSupported, NoDefaultProvider, NoDefaultSyncedFolderImpl, NoEnvironmentError, PackageIncludeMissing, PackageIncludeSymlink, PackageInvalidInfo, PackageOutputDirectory, PackageOutputExists, PackageRequiresDirectory, PluginGemNotFound, PluginInitError, PluginInstallFailed, PluginInstallLicenseNotFound, PluginInstallSpace, PluginInstallVersionConflict, PluginLoadError, PluginMissingLibrary, PluginMissingLocalError, PluginMissingRubyDev, PluginNeedsDeveloperTools, PluginNoLocalError, PluginNotInstalled, PluginSourceError, PluginStateFileParseError, PluginUninstallSystem, PowerShellError, PowerShellInvalidVersion, PowerShellNotFound, ProviderCantInstall, ProviderChecksumMismatch, ProviderInstallFailed, ProviderNotFound, ProviderNotFoundSuggestion, ProviderNotUsable, ProvisionerFlagInvalid, ProvisionerWinRMUnsupported, PushStrategyNotDefined, PushStrategyNotLoaded, PushStrategyNotProvided, PushesNotDefined, RSyncError, RSyncGuestInstallError, RSyncNotFound, RSyncNotInstalledInGuest, RSyncPostCommandError, SCPPermissionDenied, SCPUnavailable, SSHAuthenticationFailed, SSHChannelOpenFail, SSHConnectEACCES, SSHConnectionAborted, SSHConnectionRefused, SSHConnectionReset, SSHConnectionTimeout, SSHDisconnected, SSHHostDown, SSHInsertKeyUnsupported, SSHInvalidShell, SSHIsPuttyLink, SSHKeyBadOwner, SSHKeyBadPermissions, SSHKeyTypeNotSupported, SSHNoExitStatus, SSHNoRoute, SSHNotReady, SSHRunRequiresKeys, SSHUnavailable, SSHUnavailableWindows, SharedFolderCreateFailed, ShellExpandFailed, SnapshotConflictFailed, SnapshotNotFound, SnapshotNotSupported, SyncedFolderUnusable, TriggersBadExitCodes, TriggersGuestNotExist, TriggersGuestNotRunning, TriggersNoBlockGiven, TriggersNoStageGiven, UIExpectsTTY, UnimplementedProviderAction, UploadInvalidCompressionType, UploadMissingExtractCapability, UploadMissingTempCapability, UploadSourceMissing, UploaderError, VBoxManageError, VBoxManageLaunchError, VBoxManageNotFoundError, VMBaseMacNotSpecified, VMBootBadState, VMBootTimeout, VMCloneFailure, VMCreateMasterFailure, VMCustomizationFailed, VMImportFailure, VMInaccessible, VMNameExists, VMNoMatchError, VMNotCreatedError, VMNotFoundError, VMNotRunningError, VMPowerOffToPackage, VagrantInterrupt, VagrantLocked, VagrantRemoteError, VagrantVersionBad, VagrantfileExistsError, VagrantfileLoadError, VagrantfileNameError, VagrantfileSyntaxError, VagrantfileTemplateNotFoundError, VagrantfileWriteError, VirtualBoxBrokenVersion040214, VirtualBoxConfigNotFound, VirtualBoxDisksControllerNotFound, VirtualBoxDisksDefinedExceedLimit, VirtualBoxDisksNoSupportedControllers, VirtualBoxDisksPrimaryNotFound, VirtualBoxDisksUnsupportedController, VirtualBoxGuestPropertyNotFound, VirtualBoxInstallIncomplete, VirtualBoxInvalidHostSubnet, VirtualBoxInvalidVersion, VirtualBoxKernelModuleNotLoaded, VirtualBoxMachineFolderNotFound, VirtualBoxMountFailed, VirtualBoxMountNotSupportedBSD, VirtualBoxNameExists, VirtualBoxNoName, VirtualBoxNoRoomForHighLevelNetwork, VirtualBoxNotDetected, VirtualBoxUserMismatch, VirtualBoxVersionEmpty, WSLRootFsNotFoundError, WSLVagrantAccessError, WSLVagrantVersionMismatch, WSLVirtualBoxWindowsAccessError, WinRMInvalidCommunicator, Plugin::V1::Guest::BaseError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ VagrantError

Returns a new instance of VagrantError.



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

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

#extra_dataObject

This is extra data passed into the message for translation.



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

def extra_data
  @extra_data
end

Class Method Details

.error_key(key = nil, namespace = nil) ⇒ Object



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

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

.error_message(message) ⇒ Object



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

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

.error_namespace(namespace) ⇒ Object



61
62
63
# File 'lib/vagrant/errors.rb', line 61

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

Instance Method Details

#error_keyObject

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



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

def error_key; nil; end

#error_messageObject

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



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

def error_message; "No error message"; end

#error_namespaceObject

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



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

def error_namespace; "vagrant.errors"; end

#status_codeInteger

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

Returns:

  • (Integer)


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

def status_code; 1; end