diff options
| author | Jack Nagel | 2014-02-18 13:27:35 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2014-02-18 13:27:35 -0500 | 
| commit | ca0eff67faaa3193ca05ee14f9d0af6797dd2a52 (patch) | |
| tree | 7456023c96709768ec7a032f399e6a3ab4f07cd3 /Library/Homebrew | |
| parent | 52f3c3b9e343f3fd7dbc860197595bed3e04dc5d (diff) | |
| download | brew-ca0eff67faaa3193ca05ee14f9d0af6797dd2a52.tar.bz2 | |
Inline static exception text to remove a rescue
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/exceptions.rb | 16 | ||||
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/resource.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_resource.rb | 2 | 
4 files changed, 8 insertions, 18 deletions
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index b03896669..66123d9f0 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -240,24 +240,20 @@ class ChecksumMissingError < ArgumentError; end  # raised by Pathname#verify_checksum when verification fails  class ChecksumMismatchError < RuntimeError -  attr_accessor :advice -  attr_reader :expected, :actual, :hash_type +  attr_reader :expected, :hash_type -  def initialize expected, actual +  def initialize fn, expected, actual      @expected = expected -    @actual = actual      @hash_type = expected.hash_type.to_s.upcase      super <<-EOS.undent        #{@hash_type} mismatch -      Expected: #{@expected} -      Actual: #{@actual} +      Expected: #{expected} +      Actual: #{actual} +      Archive: #{fn} +      To retry an incomplete download, remove the file above.        EOS    end - -  def to_s -    super + advice.to_s -  end  end  class ResourceMissingError < ArgumentError diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index f2222d37f..9e1e809db 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -237,7 +237,7 @@ class Pathname    def verify_checksum expected      raise ChecksumMissingError if expected.nil? or expected.empty?      actual = Checksum.new(expected.hash_type, send(expected.hash_type).downcase) -    raise ChecksumMismatchError.new(expected, actual) unless expected == actual +    raise ChecksumMismatchError.new(self, expected, actual) unless expected == actual    end    if '1.9' <= RUBY_VERSION diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index 4b575f0a6..490c5dfb4 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -91,12 +91,6 @@ class Resource      opoo "Cannot verify integrity of #{fn.basename}"      puts "A checksum was not provided for this resource"      puts "For your reference the SHA1 is: #{fn.sha1}" -  rescue ChecksumMismatchError => e -    e.advice = <<-EOS.undent -    Archive: #{fn} -    (To retry an incomplete download, remove the file above.) -    EOS -    raise e    end    Checksum::TYPES.each do |cksum| diff --git a/Library/Homebrew/test/test_resource.rb b/Library/Homebrew/test/test_resource.rb index b36c082d1..3cfe592e1 100644 --- a/Library/Homebrew/test/test_resource.rb +++ b/Library/Homebrew/test/test_resource.rb @@ -117,7 +117,7 @@ class ResourceTests < Test::Unit::TestCase      checksum = @resource.sha1(TEST_SHA1)      fn.expects(:verify_checksum).with(checksum). -      raises(ChecksumMismatchError.new(checksum, Object.new)) +      raises(ChecksumMismatchError.new(fn, checksum, Object.new))      shutup do        assert_raises(ChecksumMismatchError) do  | 
