diff --git a/lib/compass.rb b/lib/compass.rb index 665e5a86..d82db208 100644 --- a/lib/compass.rb +++ b/lib/compass.rb @@ -29,9 +29,6 @@ module Compass File.expand_path(File.join(File.dirname(__FILE__))) end module_function :base_directory, :lib_directory - - class Error < StandardError - end end require File.join(File.dirname(__FILE__), 'compass', 'frameworks') diff --git a/lib/compass/actions.rb b/lib/compass/actions.rb index 511fe34b..a853ee40 100644 --- a/lib/compass/actions.rb +++ b/lib/compass/actions.rb @@ -13,7 +13,7 @@ module Compass if File.exists?(to) && !options[:force] #TODO: Detect differences & provide an overwrite prompt msg = "#{basename(to)} already exists." - raise InstallationError.new(msg) + raise Compass::FilesystemConflict.new(msg) elsif File.exists?(to) logger.record :overwrite, basename(to) FileUtils.rm to unless options[:dry_run] @@ -31,7 +31,7 @@ module Compass logger.record :exists, basename(dir) elsif File.exists?(dir) msg = "#{basename(dir)} already exists and is not a directory." - raise InstallationError.new(msg) + raise Compass::FilesystemConflict.new(msg) else logger.record :directory, basename(dir) FileUtils.mkdir_p(dir) unless options[:dry_run] @@ -43,7 +43,7 @@ module Compass options ||= self.options if self.respond_to?(:options) if File.exists?(file_name) && !options[:force] msg = "File #{basename(file_name)} already exists. Run with --force to force creation." - raise InstallationError.new(msg) + raise Compass::FilesystemConflict.new(msg) end if File.exists?(file_name) logger.record :overwrite, basename(file_name) diff --git a/lib/compass/commands/update_project.rb b/lib/compass/commands/update_project.rb index ef227d6c..7e7972b2 100644 --- a/lib/compass/commands/update_project.rb +++ b/lib/compass/commands/update_project.rb @@ -52,9 +52,9 @@ module Compass def assert_project_directory_exists! if File.exists?(project_directory) && !File.directory?(project_directory) - raise Compass::Exec::ExecError.new("#{project_directory} is not a directory.") + raise Compass::FilesystemConflict.new("#{project_directory} is not a directory.") elsif !File.directory?(project_directory) - raise ::Compass::Exec::ExecError.new("#{project_directory} does not exist.") + raise Compass::Error.new("#{project_directory} does not exist.") end end diff --git a/lib/compass/errors.rb b/lib/compass/errors.rb new file mode 100644 index 00000000..d0dccfcd --- /dev/null +++ b/lib/compass/errors.rb @@ -0,0 +1,7 @@ +module Compass + class Error < StandardError + end + + class FilesystemConflict < Error + end +end \ No newline at end of file diff --git a/lib/compass/exec.rb b/lib/compass/exec.rb index 12c20e00..baa287b1 100644 --- a/lib/compass/exec.rb +++ b/lib/compass/exec.rb @@ -3,16 +3,11 @@ require 'rubygems' require 'haml' require File.join(Compass.lib_directory, 'compass', 'logger') require File.join(Compass.lib_directory, 'compass', 'configuration') +require File.join(Compass.lib_directory, 'compass', 'errors') require File.join(Compass.lib_directory, 'compass', 'actions') module Compass module Exec - class ExecError < StandardError - end - - class DirectoryExistsError < ExecError - end - def report_error(e, options) $stderr.puts "#{e.class} on line #{get_line e} of #{get_file e}: #{e.message}" @@ -51,7 +46,7 @@ module Compass perform! rescue Exception => e raise e if e.is_a? SystemExit - if e.is_a?(ExecError) || e.is_a?(OptionParser::ParseError) + if e.is_a?(::Compass::Error) || e.is_a?(OptionParser::ParseError) $stderr.puts e.message else ::Compass::Exec.report_error(e, @options) diff --git a/lib/compass/installers.rb b/lib/compass/installers.rb index 3a86dff8..a92f1a3f 100644 --- a/lib/compass/installers.rb +++ b/lib/compass/installers.rb @@ -1,15 +1,3 @@ -module Compass - module Installers - - class InstallationError < Compass::Error - end - - class DirectoryExistsError < InstallationError - end - - end -end - require File.join(File.dirname(__FILE__), 'installers', 'manifest') require File.join(File.dirname(__FILE__), 'installers', 'base') require File.join(File.dirname(__FILE__), 'installers', 'stand_alone')