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: BaseVMNotFound, BoxAlreadyExists, BoxDownloadUnknownType, BoxNotFound, BoxNotSpecified, BoxSpecifiedDoesntExist, BoxUnpackageFailure, BoxVerificationFailed, CLIInvalidOptions, CLIInvalidUsage, ConfigValidationFailed, DeprecationError, DestroyRequiresForce, DotfileIsDirectory, DownloaderFileDoesntExist, DownloaderHTTPSocketError, DownloaderHTTPStatusError, EnvironmentLockedError, EnvironmentNonExistentCWD, ForwardPortAutolistEmpty, ForwardPortCollision, ForwardPortCollisionResume, GemCommandInBundler, HomeDirectoryMigrationFailed, HomeDirectoryNotAccessible, IncompatibleWithFutureVersion, MultiVMEnvironmentRequired, MultiVMTargetRequired, NFSHostRequired, NFSNoHostNetwork, NFSNotSupported, NetworkAdapterCollision, NetworkCollision, NetworkDHCPAlreadyAttached, NetworkNoAdapters, NetworkNotFound, NoEnvironmentError, PackageIncludeMissing, PackageOutputDirectory, PackageOutputExists, PackageRequiresDirectory, PersistDotfileExists, SCPUnavailable, SSHAuthenticationFailed, SSHConnectionRefused, SSHKeyBadPermissions, SSHKeyTypeNotSupported, SSHPortNotDetected, SSHUnavailable, SSHUnavailableWindows, SharedFolderCreateFailed, UIExpectsTTY, VBoxManageError, VMBaseMacNotSpecified, VMCustomizationFailed, VMFailedToBoot, VMFailedToRun, VMGuestError, VMImportFailure, VMInaccessible, VMNoMatchError, VMNotCreatedError, VMNotFoundError, VMNotRunningError, VMPowerOffToPackage, VagrantError, VagrantInterrupt, VagrantfileExistsError, VagrantfileSyntaxError, VirtualBoxInvalidVersion, VirtualBoxKernelModuleNotLoaded, VirtualBoxNotDetected