From 76b2eee7771ecf2b339d1023699ef9f30fa3fe65 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Mon, 18 Jun 2012 19:58:35 -0500 Subject: Refactor checksumming Signed-off-by: Jack Nagel --- Library/Homebrew/exceptions.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Library/Homebrew/exceptions.rb') diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index d3e2e8936..2b7f6542c 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -148,3 +148,29 @@ end # raised by safe_system in utils.rb class ErrorDuringExecution < RuntimeError end + +# raised by Pathname#verify_checksum when cksum is nil or empty +class ChecksumMissingError < ArgumentError +end + +# raised by Pathname#verify_checksum when verification fails +class ChecksumMismatchError < RuntimeError + attr :advice, true + attr :expected + attr :actual + + def initialize expected, actual + @expected = expected + @actual = actual + + super <<-EOS.undent + #{expected.hash_type.to_s.upcase} mismatch + Expected: #{expected} + Actual: #{actual} + EOS + end + + def to_s + super + advice + end +end -- cgit v1.2.3