Module: Vagrant::Errors

Defined in:
lib/vagrant/errors.rb

Overview

This module contains all of the internal errors in Vagrant's core. These errors are expected errors and as such don't typically represent bugs in Vagrant itself. These are meant as a way to detect errors and display them in a user-friendly way.

Defining a new Error

To define a new error, inherit from VagrantError, which lets Vagrant know that this is an expected error, and also gives you some helpers for providing exit codes and error messages. An example is shown below, then it is explained:

class MyError < Vagrant::Errors::VagrantError
  error_key "my_error"
end

This creates an error with an I18n error key of "my_error." VagrantError uses I18n to look up error messages, in the "vagrant.errors" namespace. So in the above, the error message would be the translation of "vagrant.errors.my_error"

If you don't want to use I18n, you can override the #initialize method and set your own error message.

Raising an Error

To raise an error, it is nothing special, just raise it like any normal exception:

raise MyError.new

Eventually this exception will bubble out to the vagrant binary which will show a nice error message. And if it is raised in the middle of a middleware sequence, then Action::Warden will catch it and begin the recovery process prior to exiting.

Defined Under Namespace

Classes: 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, CommandUnavailableWindows, CommunicatorNotFound, ConfigInvalid, ConfigUpgradeErrors, CopyPrivateKeyFailed, CorruptMachineIndex, DarwinNFSMountFailed, DestroyRequiresForce, DotfileUpgradeJSONError, DownloaderError, DownloaderInterrupted, 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, NetSSHException, NetworkCollision, NetworkDHCPAlreadyAttached, NetworkNotFound, NoDefaultProvider, NoDefaultSyncedFolderImpl, NoEnvironmentError, PackageIncludeMissing, PackageIncludeSymlink, PackageOutputDirectory, PackageOutputExists, PackageRequiresDirectory, PluginGemNotFound, PluginInstallLicenseNotFound, PluginInstallSpace, PluginInstallVersionConflict, PluginLoadError, PluginNotInstalled, PluginStateFileParseError, PluginUninstallSystem, ProviderNotFound, ProviderNotUsable, ProvisionerFlagInvalid, ProvisionerWinRMUnsupported, PushStrategyNotDefined, PushStrategyNotLoaded, PushStrategyNotProvided, PushesNotDefined, RSyncError, RSyncNotFound, RSyncNotInstalledInGuest, SCPPermissionDenied, SCPUnavailable, SSHAuthenticationFailed, SSHChannelOpenFail, SSHConnectEACCES, SSHConnectionRefused, SSHConnectionReset, SSHConnectionTimeout, SSHDisconnected, SSHHostDown, SSHInsertKeyUnsupported, 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, VagrantError, VagrantInterrupt, VagrantVersionBad, VagrantfileExistsError, VagrantfileLoadError, VagrantfileSyntaxError, VagrantfileWriteError, VirtualBoxBrokenVersion040214, VirtualBoxGuestPropertyNotFound, VirtualBoxInstallIncomplete, VirtualBoxInvalidVersion, VirtualBoxKernelModuleNotLoaded, VirtualBoxNameExists, VirtualBoxNoName, VirtualBoxNoRoomForHighLevelNetwork, VirtualBoxNotDetected, VirtualBoxVersionEmpty