Exception: Vagrant::Errors::VagrantError
- Inherits:
-
StandardError
- Object
- StandardError
- Vagrant::Errors::VagrantError
- 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
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, 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, VagrantInterrupt, VagrantfileExistsError, VagrantfileSyntaxError, VirtualBoxInvalidVersion, VirtualBoxKernelModuleNotLoaded, VirtualBoxNotDetected, Guest::Base::BaseError, Guest::FreeBSD::FreeBSDError, Guest::Linux::LinuxError, Guest::Solaris::SolarisError, Hosts::FreeBSD::FreeBSDHostError, Provisioners::Chef::ChefError, Provisioners::PuppetError, Provisioners::PuppetServerError
Constant Summary collapse
- @@used_codes =
[]
Class Method Summary collapse
- .error_key(key = nil, namespace = nil) ⇒ Object
- .error_namespace(namespace) ⇒ Object
- .status_code(code = nil) ⇒ Object
Instance Method Summary collapse
-
#error_key ⇒ Object
The key for the error message.
-
#error_namespace ⇒ Object
The default error namespace which is used for the error key.
-
#initialize(message = nil, *args) ⇒ VagrantError
constructor
A new instance of VagrantError.
Constructor Details
#initialize(message = nil, *args) ⇒ VagrantError
Returns a new instance of VagrantError.
66 67 68 69 70 71 72 |
# File 'lib/vagrant/errors.rb', line 66 def initialize(=nil, *args) = { :_key => } if && !.is_a?(Hash) = { :_key => error_key, :_namespace => error_namespace }.merge( || {}) = translate_error() super end |
Class Method Details
.error_key(key = nil, namespace = nil) ⇒ Object
57 58 59 60 |
# File 'lib/vagrant/errors.rb', line 57 def self.error_key(key=nil, namespace=nil) define_method(:error_key) { key } error_namespace(namespace) if namespace end |
.error_namespace(namespace) ⇒ Object
62 63 64 |
# File 'lib/vagrant/errors.rb', line 62 def self.error_namespace(namespace) define_method(:error_namespace) { namespace } end |
.status_code(code = nil) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/vagrant/errors.rb', line 48 def self.status_code(code = nil) if code raise "Status code already in use: #{code}" if @@used_codes.include?(code) @@used_codes << code end define_method(:status_code) { code } end |
Instance Method Details
#error_key ⇒ Object
The key for the error message. This should be set using the error_key method but can be overridden here if needed.
81 |
# File 'lib/vagrant/errors.rb', line 81 def error_key; nil; end |
#error_namespace ⇒ Object
The default error namespace which is used for the error key. This can be overridden here or by calling the "error_namespace" class method.
77 |
# File 'lib/vagrant/errors.rb', line 77 def error_namespace; "vagrant.errors"; end |