Moved errors out into its own file so that vagrant.rb doesn't get too cluttered

This commit is contained in:
Mitchell Hashimoto 2010-08-24 11:18:29 -07:00
parent cc2dcf4d8f
commit 004ba551a6
2 changed files with 16 additions and 16 deletions

View File

@ -1,6 +1,7 @@
require 'json'
require 'virtualbox'
require "vagrant/util/glob_loader"
require 'vagrant/errors'
require 'vagrant/util/glob_loader'
module Vagrant
# TODO: Move more classes over to the autoload model. We'll
@ -13,22 +14,11 @@ module Vagrant
autoload :GroupBase, 'vagrant/command/group_base'
end
class << self
# The source root is the path to the root directory of
# the Vagrant gem.
def source_root
@source_root ||= File.expand_path('../../', __FILE__)
end
# The source root is the path to the root directory of
# the Vagrant gem.
def self.source_root
@source_root ||= File.expand_path('../../', __FILE__)
end
class VagrantError < StandardError
def self.status_code(code = nil)
define_method(:status_code) { code }
end
end
class CLIMissingEnvironment < VagrantError; status_code(1); end
class BoxNotFound < VagrantError; status_code(2); end
end
# Load them up. One day we'll convert this to autoloads. Today

10
lib/vagrant/errors.rb Normal file
View File

@ -0,0 +1,10 @@
module Vagrant
class VagrantError < StandardError
def self.status_code(code = nil)
define_method(:status_code) { code }
end
end
class CLIMissingEnvironment < VagrantError; status_code(1); end
class BoxNotFound < VagrantError; status_code(2); end
end