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.
Files changed (3) hide show
  1. data/lib/dl.rb +1 -1
  2. data/lib/dl/dl.rb +24 -3
  3. metadata +1 -1
data/lib/dl.rb CHANGED
@@ -3,7 +3,7 @@ require 'patron'
3
3
  require 'dl/dl'
4
4
 
5
5
  module Dl
6
- VERSION = "1.2.0"
6
+ VERSION = "1.2.1"
7
7
 
8
8
  @@be_quiet = false
9
9
  @@file = ""
data/lib/dl/dl.rb CHANGED
@@ -4,9 +4,30 @@ module Dl
4
4
 
5
5
  output "Downloading #{url}..."
6
6
 
7
- response = session.get url
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
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.0
5
+ version: 1.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mark Szymanski