2010-08-24 18:18:29 +00:00
|
|
|
module Vagrant
|
2010-08-27 06:21:28 +00:00
|
|
|
module Errors
|
|
|
|
# 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.
|
|
|
|
class VagrantError < StandardError
|
|
|
|
def self.status_code(code = nil)
|
|
|
|
define_method(:status_code) { code }
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.error_key(key=nil)
|
|
|
|
define_method(:error_key) { key }
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(message=nil, *args)
|
|
|
|
message = translate_error(error_key, message) if respond_to?(:error_key)
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def translate_error(key, opts=nil)
|
|
|
|
I18n.t("vagrant.errors.#{key}", opts)
|
|
|
|
end
|
2010-08-24 18:18:29 +00:00
|
|
|
end
|
2010-08-27 04:56:38 +00:00
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class BaseVMNotFound < VagrantError
|
|
|
|
status_code(6)
|
|
|
|
error_key(:base_vm_not_found)
|
2010-08-27 04:56:38 +00:00
|
|
|
end
|
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class BoxNotFound < VagrantError
|
|
|
|
status_code(2)
|
|
|
|
error_key(:box_not_found)
|
2010-08-27 04:56:38 +00:00
|
|
|
end
|
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class CLIMissingEnvironment < VagrantError
|
|
|
|
status_code(1)
|
|
|
|
error_key(:cli_missing_env)
|
|
|
|
end
|
2010-08-27 04:56:38 +00:00
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class MultiVMEnvironmentRequired < VagrantError
|
|
|
|
status_code(5)
|
|
|
|
error_key(:multi_vm_required)
|
|
|
|
end
|
2010-08-27 04:56:38 +00:00
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class MultiVMTargetRequired < VagrantError
|
|
|
|
status_code(7)
|
|
|
|
error_key(:multi_vm_target_required)
|
|
|
|
end
|
2010-08-24 18:18:29 +00:00
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class NoEnvironmentError < VagrantError
|
|
|
|
status_code(3)
|
|
|
|
error_key(:no_env)
|
|
|
|
end
|
2010-08-27 04:56:38 +00:00
|
|
|
|
2010-08-27 06:51:30 +00:00
|
|
|
class SSHUnavailableWindows < VagrantError
|
|
|
|
status_code(10)
|
|
|
|
error_key(:ssh_unavailable_windows)
|
|
|
|
end
|
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class VirtualBoxInvalidOSE < VagrantError
|
|
|
|
status_code(9)
|
|
|
|
error_key(:virtualbox_invalid_ose)
|
|
|
|
end
|
2010-08-27 04:56:38 +00:00
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class VirtualBoxInvalidVersion < VagrantError
|
|
|
|
status_code(9)
|
|
|
|
error_key(:virtualbox_invalid_version)
|
|
|
|
end
|
2010-08-27 04:56:38 +00:00
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class VirtualBoxNotDetected < VagrantError
|
|
|
|
status_code(8)
|
|
|
|
error_key(:virtualbox_not_detected)
|
|
|
|
end
|
2010-08-27 04:56:38 +00:00
|
|
|
|
2010-08-27 06:21:28 +00:00
|
|
|
class VMNotCreatedError < VagrantError
|
|
|
|
status_code(6)
|
|
|
|
error_key(:vm_creation_required)
|
|
|
|
end
|
|
|
|
|
|
|
|
class VMNotFoundError < VagrantError
|
|
|
|
status_code(4)
|
|
|
|
error_key(:vm_not_found)
|
|
|
|
end
|
2010-08-27 04:56:38 +00:00
|
|
|
end
|
2010-08-24 18:18:29 +00:00
|
|
|
end
|