imperium 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f59bdee1b6ac9ba26ac29376201e2287dc2a0d40
4
- data.tar.gz: 607de30419fe22615ff7449c70e27f8757520278
3
+ metadata.gz: 85fe923e6229f7ef7185879ff446dfa52e05a07c
4
+ data.tar.gz: b5fffc62dc2506526e73e617e2b0657fe0268959
5
5
  SHA512:
6
- metadata.gz: f14950628947bcf8e279b07d6ad39d3cf812347d5899962fbfef983c03a461434ceca309eb17973c0d3e9917d31252cd44ae762774d0f99cf828c982b542c45e
7
- data.tar.gz: 99ce04ef3f3cf342bcf51b0566acfee85b6f7daa97b99e902bffe04670377de1b536c22bac5217cba571cc6329920574fabd8396673acc7567b77aa138d6e63c
6
+ metadata.gz: dd538bb71db19a0300ae2e10aeffbc83f0aa42d24540377bffc39bc9d47a7b3e7be09ed256ef85382761e5ae0a79d74cdaaa8c8f6f6382e87c60180f44e8ee4b
7
+ data.tar.gz: 25f8e50b3483110b5d74fd2c83a0711be2d71922039d9fcb5046db0ed433f25603ca53b528e1b851fda781466c668e9c617a66fa5e6aa4fef5f9f9a243955831
@@ -15,4 +15,7 @@ module Imperium
15
15
 
16
16
  # Raised when the remote server took too long to respond.
17
17
  class ReceiveTimeout < TimeoutError; end
18
+
19
+ # Raised when we can't open a socket to the specified consul server
20
+ class UnableToConnectError < SocketError; end
18
21
  end
@@ -13,14 +13,14 @@ module Imperium
13
13
  end
14
14
 
15
15
  def delete(path)
16
- wrapping_timeouts do
16
+ wrapping_exceptions do
17
17
  url = config.url.join(path)
18
18
  @driver.delete(url)
19
19
  end
20
20
  end
21
21
 
22
22
  def get(path, query: {})
23
- wrapping_timeouts do
23
+ wrapping_exceptions do
24
24
  url = config.url.join(path)
25
25
  url.query_values = query
26
26
  @driver.get(url, header: build_request_headers)
@@ -28,7 +28,7 @@ module Imperium
28
28
  end
29
29
 
30
30
  def put(path, value)
31
- wrapping_timeouts do
31
+ wrapping_exceptions do
32
32
  url = config.url.join(path)
33
33
  @driver.put(url, body: value)
34
34
  end
@@ -46,13 +46,19 @@ module Imperium
46
46
 
47
47
  # We're doing this wrap and re-raise dance to give a more consistent set of
48
48
  # exceptions that can come from us.
49
- def wrapping_timeouts
49
+ def wrapping_exceptions
50
50
  yield
51
- rescue HTTPClient::ConnectTimeout => ex
51
+ rescue SocketError => ex
52
+ if ex.message.start_with?("getaddrinfo: Name or service not known")
53
+ raise Imperium::UnableToConnectError, ex.message
54
+ else
55
+ raise
56
+ end
57
+ rescue ::HTTPClient::ConnectTimeoutError => ex
52
58
  raise Imperium::ConnectTimeout, ex.message
53
- rescue HTTPClient::SendTimeout => ex
59
+ rescue ::HTTPClient::SendTimeoutError => ex
54
60
  raise Imperium::SendTimeout, ex.message
55
- rescue HTTPClient::ReceiveTimeout => ex
61
+ rescue ::HTTPClient::ReceiveTimeoutError => ex
56
62
  raise Imperium::ReceiveTimeout, ex.message
57
63
  end
58
64
  end
@@ -1,3 +1,3 @@
1
1
  module Imperium
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Pickett