Consolodate error classes.
This commit is contained in:
parent
9e80847ac7
commit
c0c422c373
@ -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')
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
7
lib/compass/errors.rb
Normal file
7
lib/compass/errors.rb
Normal file
@ -0,0 +1,7 @@
|
||||
module Compass
|
||||
class Error < StandardError
|
||||
end
|
||||
|
||||
class FilesystemConflict < Error
|
||||
end
|
||||
end
|
@ -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)
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user