lib/dl/dl.rb in dl-1.2.0 vs lib/dl/dl.rb in dl-1.2.1
- old
+ new
@@ -2,12 +2,33 @@
def self.download(url, raw = false)
session = Patron::Session.new
output "Downloading #{url}..."
- response = session.get url
-
-
+ begin
+ response = session.get url
+ rescue Patron::HostResolutionError
+ puts "Error resolving remote host."
+ exit 1
+ rescue Patron::PartialFileError
+ puts "File size mismatch. (Host reported a file size, but the actual file is of different size)"
+ exit 1
+ rescue Patron::TimeoutError
+ puts "Operation timed out."
+ exit 1
+ rescue Patron::TooManyRedirects
+ puts "Tried redirecting too many times."
+ exit 1
+ rescue Patron::URLFormatError
+ puts "Error with the URL format"
+ exit 1
+ rescue Patron::UnsupportedProtocol
+ puts "This URL is using a protocol that we cannot handle."
+ exit 1
+ rescue Patron::ConnectionFailed
+ puts "Error connecting to host. Check your internet connection."
+ exit 1
+ end
if raw == true
puts response.body
else
if Dl::file != nil
filename = Dl::file