aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/exceptions.rb
diff options
context:
space:
mode:
authorJack Nagel2012-06-18 19:58:35 -0500
committerJack Nagel2012-07-04 22:47:33 -0500
commit0c18ffd7fa23c5a5149798aea10fab25b4670e96 (patch)
tree059672cef33544b94ad2be6dbaf7de926210a91b /Library/Homebrew/exceptions.rb
parent3642b5b4f4efb6bc0ecc9875fd1d0faef838a3d3 (diff)
downloadhomebrew-0c18ffd7fa23c5a5149798aea10fab25b4670e96.tar.bz2
Refactor checksumming
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/exceptions.rb')
-rw-r--r--Library/Homebrew/exceptions.rb26
1 files changed, 26 insertions, 0 deletions
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