imperium 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/imperium/error.rb +3 -0
- data/lib/imperium/http_client.rb +13 -7
- data/lib/imperium/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85fe923e6229f7ef7185879ff446dfa52e05a07c
|
4
|
+
data.tar.gz: b5fffc62dc2506526e73e617e2b0657fe0268959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd538bb71db19a0300ae2e10aeffbc83f0aa42d24540377bffc39bc9d47a7b3e7be09ed256ef85382761e5ae0a79d74cdaaa8c8f6f6382e87c60180f44e8ee4b
|
7
|
+
data.tar.gz: 25f8e50b3483110b5d74fd2c83a0711be2d71922039d9fcb5046db0ed433f25603ca53b528e1b851fda781466c668e9c617a66fa5e6aa4fef5f9f9a243955831
|
data/lib/imperium/error.rb
CHANGED
data/lib/imperium/http_client.rb
CHANGED
@@ -13,14 +13,14 @@ module Imperium
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def delete(path)
|
16
|
-
|
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
|
-
|
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
|
-
|
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
|
49
|
+
def wrapping_exceptions
|
50
50
|
yield
|
51
|
-
rescue
|
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::
|
59
|
+
rescue ::HTTPClient::SendTimeoutError => ex
|
54
60
|
raise Imperium::SendTimeout, ex.message
|
55
|
-
rescue HTTPClient::
|
61
|
+
rescue ::HTTPClient::ReceiveTimeoutError => ex
|
56
62
|
raise Imperium::ReceiveTimeout, ex.message
|
57
63
|
end
|
58
64
|
end
|
data/lib/imperium/version.rb
CHANGED