dl 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dl.rb +1 -1
- data/lib/dl/dl.rb +24 -3
- metadata +1 -1
data/lib/dl.rb
CHANGED
data/lib/dl/dl.rb
CHANGED
@@ -4,9 +4,30 @@ module Dl
|
|
4
4
|
|
5
5
|
output "Downloading #{url}..."
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
begin
|
8
|
+
response = session.get url
|
9
|
+
rescue Patron::HostResolutionError
|
10
|
+
puts "Error resolving remote host."
|
11
|
+
exit 1
|
12
|
+
rescue Patron::PartialFileError
|
13
|
+
puts "File size mismatch. (Host reported a file size, but the actual file is of different size)"
|
14
|
+
exit 1
|
15
|
+
rescue Patron::TimeoutError
|
16
|
+
puts "Operation timed out."
|
17
|
+
exit 1
|
18
|
+
rescue Patron::TooManyRedirects
|
19
|
+
puts "Tried redirecting too many times."
|
20
|
+
exit 1
|
21
|
+
rescue Patron::URLFormatError
|
22
|
+
puts "Error with the URL format"
|
23
|
+
exit 1
|
24
|
+
rescue Patron::UnsupportedProtocol
|
25
|
+
puts "This URL is using a protocol that we cannot handle."
|
26
|
+
exit 1
|
27
|
+
rescue Patron::ConnectionFailed
|
28
|
+
puts "Error connecting to host. Check your internet connection."
|
29
|
+
exit 1
|
30
|
+
end
|
10
31
|
if raw == true
|
11
32
|
puts response.body
|
12
33
|
else
|